Music Downloader
I DJ, and I used to spend hours finding tracks, checking their quality, converting, tagging and filing them. This project cuts all of that to one command: the track is found on SoundMesh, a peer-to-peer network, downloaded at the best available quality, converted to lossless, imported into my library and filed by genre and energy level, ready for rekordbox.
The flow
One command, seven steps, zero intervention. Each step was hardened against a problem hit in real use.
One command
meshd track "Artist" "Title" "Genre" is the only input needed.
Library check
Already lossless: it stops there. Only in MP3: it switches to the upgrade flow. No duplicates.
Escalating search
A precise query first, then wider and wider until a valid source shows up. The network connection repairs itself if it drops.
Quality and error filter
Lossless first, MP3 320 accepted, everything else rejected. A match check discards files that are not the right track (unwanted remix, another title by the same artist).
Download with fallback
If a source rejects or blocks, the next one takes over, up to five tries. Metadata (genre, artist, title) travels with the file.
Automatic conversion and import
FLAC and WAV become AIFF (lossless, readable by the decks), MP3 320 is kept as is. The file lands in the Music app import folder, which ingests it on its own.
Filing
Genre tagged, added to the matching playlist, energy tag (E1 warm-up, E2 mid, E3 peak): the track is ready to play.
The tools
The core flow only needs Docker and the Python standard library. Audio analysis is the only module with scientific dependencies.
| Component | Role |
|---|---|
| meshd (CLI) | A single-file Python orchestrator, around 3,000 lines. Drives the daemon's REST API and the Music app via AppleScript. |
| P2P daemon | Self-hosted SoundMesh client in Docker, local REST API for search and transfers. |
| Conversion hook | Shell script triggered on every finished download: ffmpeg transcode, real bitrate check, MIME check, metadata. |
| Music app | Watched folder for automatic import; reads and writes genres, playlists and tags via AppleScript. |
| Energy engine | librosa analysis of the full track, intra-genre percentile score, E1/E2/E3 buckets and vocal detection. A homegrown alternative to a paid tool. |
| Queue | Retry with a file lock, normalized keys (artist order, accents) and due dates: no duplicates, no network spam. |
Three modes
The same code serves three distinct uses.
Download
Acquire a new track, from search to filing.
meshd track "Artist" "Title" "Genre"Upgrade
Replace the library's MP3s with lossless, playlists preserved; the old file goes to a review list, never deleted blindly.
meshd upgrade-batch --playlist=X --applyScore energy
Rate each track E1/E2/E3 to build sets, with cached analyses.
meshd energy-analyze --genre=X --applyThree iterations
Each version closed a family of problems seen in real use, no speculative features.
Foundations
Automation
Robustness
What's next
The owned backlog: leads identified, noted, and deliberately left aside until the pain justifies them.
Search by compilation
When a single can't be found on its own, look for it through the artist's known albums and compilations already in the library.
Validate energy by ear
Build a reference set per genre (tracks whose bucket is certain) to measure the score's correlation cleanly, and improve the heterogeneous genres where the current model slips.
Crowd-sourced signal
Cross the energy score with track positions in public sets: a track played late by many DJs is probably a peak.
Package and share
Extract the personal config, document the install and publish the tool so another DJ can deploy it.