Jopik & Qwerty
Qwerty Qwerty
Hey Jopik, I just started a tiny music bot that learns your mood and auto‑builds playlists—thought we could test it with some of your retro platformer jams. Want to see if it can predict which tracks keep you on your snack break?
Jopik Jopik
Sounds lit, fam! 🎮🍿 Let’s see if it can keep the vibes popping while I munch on my chips—send it over!
Qwerty Qwerty
Here’s the little bot in plain text – just copy it into a file called bot.py and run python bot.py. import spotipy, csv, random from spotipy.oauth2 import SpotifyOAuth # auth – replace with your own client id/secret sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope="user-read-recently-played user-modify-playback-state")) def fetch_recent_tracks(): tracks = sp.current_user_recently_played(limit=10).get('items', []) return [(t['track']['name'], t['track']['artists'][0]['name']) for t in tracks] def mood_classifier(track_name): # super‑simple heuristic – you can swap in a model later if any(word in track_name.lower() for word in ['love', 'happy', 'sun']): return 'chill' elif any(word in track_name.lower() for word in ['night', 'dark', 'slow']): return 'lofi' else: return 'neutral' def build_playlist(moods): # pick a random song from a pre‑built mood folder (you'll need to create these) song_choices = { 'chill': ['song_a', 'song_b'], 'lofi': ['song_c', 'song_d'], 'neutral': ['song_e', 'song_f'] } playlist = [] for m in moods: playlist.append(random.choice(song_choices.get(m, ['song_e']))) return playlist def push_playlist(playlist): # create a local playlist (you’ll need a client ID that can create playlists) user_id = sp.me()['id'] pl = sp.user_playlist_create(user_id, name='SnackVibes', public=False) tracks = [f"spotify:track:{t}" for t in playlist] sp.playlist_add_items(pl['id'], tracks) print(f"Playlist {pl['name']} added with {len(tracks)} tracks.") def log_actions(action): with open('bot_log.csv', 'a', newline='') as f: writer = csv.writer(f) writer.writerow([action]) def main(): recent = fetch_recent_tracks() moods = [mood_classifier(name) for name, artist in recent] playlist = build_playlist(moods) push_playlist(playlist) log_actions(f"Built playlist from moods: {moods}") if __name__ == "__main__": main() Edge case: if your Wi‑Fi drops mid‑push the bot retries three times before giving up. If you’re on battery, it will only pull the last five tracks to save data. Run it, munch on those chips, and let me know if the vibe stays on point or if you hit a hiccup. Happy debugging, and enjoy the music!
Jopik Jopik
Nice! 🎉 I’ll fire it up, keep an eye on the console, and hit you back if anything weird pops up. If it drops a beat instead of a bug, we’ll tweak it. Let me know how the mood‑predicting playlist vibes!
Qwerty Qwerty
Sounds like a plan—just keep an eye on that retry counter; if it gets stuck, add a short sleep before the next try. Once the playlist lands, test the mood tags by blasting a few tracks you’re sure should hit “chill” or “lofi” and see if the bot lands on the right folder. If the playlist feels off, log the raw track names and tweak the heuristic—maybe add a blacklist for that one glitchy pop hit that always trips it up. Let me know what the console shows, and we’ll fine‑tune the algorithm before your next chip crunch.
Jopik Jopik
Got it—watch the counter, add a sleep if it stalls, and log those raw names so we can tweak the tags. I’ll hit it now, munch a few chips, and ping you with the console output. Let’s get that playlist feeling spot on! 🚀🍟
Qwerty Qwerty
Nice, keep an eye on that retry log, add a short sleep if it stalls, and we’ll fine‑tune the tags once you drop the output. Hit it up and let me know how the vibes stack up—ready to tweak!
Jopik Jopik
Running it now—hitting the console in 2…1… 🚀 🔄 Retry counter: 0 (all good) 🎧 Recent tracks: 1. “Pixel Quest (Level 1)” – RetroGame 2. “Neon Nights” – SynthWave 3. “Bouncy Bites” – LoFiBaker Mood tags: chill, lofi, neutral Playlist built: ['song_a', 'song_c', 'song_e'] ✅ Playlist “SnackVibes” created with 3 tracks. Looks solid, but “Neon Nights” is flagged lofi though it feels more chill. Maybe add “night” to the chill list? Also, the “Bouncy Bites” is kinda pop‑y, might want to blacklist “Bouncy” from the neutral list. Let me know which tweaks you want!
Qwerty Qwerty
Great run, looks like the bot is pulling tracks and pushing a playlist without hiccups. For “Neon Nights” adding “night” to the chill list makes sense—just tweak the mood_classifier: ``` if any(word in track_name.lower() for word in ['love','happy','sun','night']): return 'chill' ``` For the pop‑y “Bouncy Bites” blacklist the word “bouncy” from neutral: ``` if 'bouncy' in track_name.lower(): return 'neutral' # or maybe skip adding it entirely ``` If you want to completely exclude it, add a small skip check before adding to moods. That should push the vibe in the right direction. Hit it again and we’ll see how the new tags play out. Good job on the first pass!
Jopik Jopik
Got the tweak idea—adding “night” to chill and black‑listing “bouncy” from neutral. I’ll update the classifier, run it again, and let you know how the new vibes land. Keep those chips ready! 🎮🍿