Scanella & Pixilune
Ever thought about a playlist that scrambles itself every minute but still vibes with your mood? let’s hack the system together.
That sounds like the ultimate mash‑up of chaos and order. I could set up a script that pulls tracks from my library, tags them by tempo and key, then uses a mood‑detecting algorithm to shuffle only those that fit the vibe. I’d run it on a loop, every minute, so the playlist is always fresh but never jarring. We could use a simple rule‑engine to keep the energy steady, and then just let the AI do the rest—although I might still check the list once a day just to make sure it’s not going totally off the rails. Want to dive into the code together?
Sounds insane, but also super rad. I’ll jam with you—grab the code, toss some random filters, and let the playlist remix itself. Just keep a sanity checkpoint, or it’ll start playing whale songs at 3 am. Let’s get glitching!
Alright, let’s fire up the auto‑shuffle engine. Here’s a quick Python skeleton with a sanity filter and a midnight reset. You can drop in whatever random filter you like—genre, BPM, even a cheeky “whale song” flag to make sure it stays sane.
```python
import random, time, datetime
from pathlib import Path
from mutagen.mp3 import MP3 # or another tag library
# Path to your music folder
MUSIC_DIR = Path("/home/user/Music")
# Load all tracks once
tracks = [f for f in MUSIC_DIR.glob("*.mp3") if f.is_file()]
def get_track_tags(file):
audio = MP3(file)
return {
"bpm": audio.get("TBPM", [0])[0], # fallback to 0 if missing
"genre": audio.get("TCON", ["unknown"])[0]
}
def sanity_check(current_track):
tags = get_track_tags(current_track)
# Block whale songs after midnight
if datetime.datetime.now().hour < 6:
if "whale" in tags["genre"].lower():
return False
return True
def random_filter(track):
# Example filter: only allow tracks with BPM 90‑140
tags = get_track_tags(track)
return 90 <= int(tags["bpm"]) <= 140
def play_next():
shuffled = [t for t in tracks if random_filter(t)]
random.shuffle(shuffled)
for track in shuffled:
if sanity_check(track):
# Replace this with your actual player command
print(f"Playing: {track.name}")
# e.g., os.system(f"mpv '{track}'")
time.sleep(30) # simulate 30‑second chunk
else:
print(f"Skipping (sanity): {track.name}")
def midnight_reset():
# Every day at 2 AM, clear the playlist to avoid whale songs
print("Midnight reset: clearing playlist cache")
while True:
play_next()
# Wait a minute between shuffles
time.sleep(60)
# Simple midnight check
if datetime.datetime.now().hour == 2:
midnight_reset()
```
Just tweak `random_filter` to throw in your own quirks, and you’re good to go. I’ll keep an eye on the whale‑song counter so we don’t get a 3 AM symphony. Happy glitching!
Nice skeleton—looks like you’ve got the chaos engine ready. One quick tweak: make `random_filter` pick a random BPM range each loop so the energy stays fresh. Also, add a small “whale‑song” counter; if it hits two in a row, reset the shuffle list entirely. That keeps the midnight reset from being a snooze‑button. Let me know if you want a sample filter to drop in. Happy remixing!
Got it, here’s the updated snippet with a dynamic BPM range and the whale‑song counter. I’ll add a tiny sample filter you can swap in later.
```python
import random, time, datetime
from pathlib import Path
from mutagen.mp3 import MP3
MUSIC_DIR = Path("/home/user/Music")
tracks = [f for f in MUSIC_DIR.glob("*.mp3") if f.is_file()]
whale_counter = 0
def get_track_tags(file):
audio = MP3(file)
return {
"bpm": int(audio.get("TBPM", [0])[0]),
"genre": audio.get("TCON", ["unknown"])[0].lower()
}
def random_bpm_range():
# Pick a fresh range each shuffle: 80‑140, 140‑200, or 200‑260
ranges = [(80, 140), (140, 200), (200, 260)]
return random.choice(ranges)
def random_filter(track, bpm_min, bpm_max):
tags = get_track_tags(track)
return bpm_min <= tags["bpm"] <= bpm_max
def sanity_check(current_track):
tags = get_track_tags(current_track)
if datetime.datetime.now().hour < 6 and "whale" in tags["genre"]:
return False
return True
def play_next():
global whale_counter
bpm_min, bpm_max = random_bpm_range()
shuffled = [t for t in tracks if random_filter(t, bpm_min, bpm_max)]
random.shuffle(shuffled)
for track in shuffled:
if not sanity_check(track):
print(f"Skipping (sanity): {track.name}")
continue
# Sample extra filter: skip tracks shorter than 30s
if get_track_tags(track)["bpm"] < 30:
print(f"Skipping (short): {track.name}")
continue
print(f"Playing: {track.name}")
# Replace with your player call
time.sleep(30)
# Whale logic
if "whale" in get_track_tags(track)["genre"]:
whale_counter += 1
if whale_counter >= 2:
print("Two whales in a row! Resetting playlist.")
whale_counter = 0
tracks[:] = [f for f in MUSIC_DIR.glob("*.mp3") if f.is_file()]
else:
whale_counter = 0
while True:
play_next()
time.sleep(60)
if datetime.datetime.now().hour == 2:
print("Midnight reset: clearing playlist cache")
```
Feel free to replace the “short track” check with whatever quirky rule you want. Happy remixing!