2025 - 2026

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.

PythonDockerffmpegAppleScriptlibrosa

The flow

One command, seven steps, zero intervention. Each step was hardened against a problem hit in real use.

01

One command

meshd track "Artist" "Title" "Genre" is the only input needed.

02

Library check

Already lossless: it stops there. Only in MP3: it switches to the upgrade flow. No duplicates.

03

Escalating search

A precise query first, then wider and wider until a valid source shows up. The network connection repairs itself if it drops.

04

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).

05

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.

06

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.

07

Filing

Genre tagged, added to the matching playlist, energy tag (E1 warm-up, E2 mid, E3 peak): the track is ready to play.

What if the track can't be found? It joins a persistent queue. A nightly job retries the entries that are due: rarities eventually resolve as other peers come online.

The tools

The core flow only needs Docker and the Python standard library. Audio analysis is the only module with scientific dependencies.

ComponentRole
meshd (CLI)A single-file Python orchestrator, around 3,000 lines. Drives the daemon's REST API and the Music app via AppleScript.
P2P daemonSelf-hosted SoundMesh client in Docker, local REST API for search and transfers.
Conversion hookShell script triggered on every finished download: ffmpeg transcode, real bitrate check, MIME check, metadata.
Music appWatched folder for automatic import; reads and writes genres, playlists and tags via AppleScript.
Energy enginelibrosa analysis of the full track, intra-genre percentile score, E1/E2/E3 buckets and vocal detection. A homegrown alternative to a paid tool.
QueueRetry 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.

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 --apply

Score energy

Rate each track E1/E2/E3 to build sets, with cached analyses.

meshd energy-analyze --genre=X --apply

Three iterations

Each version closed a family of problems seen in real use, no speculative features.

v1

Foundations

API search and downloadquality filtersession cache
v2

Automation

conversion hookembedded metadataplaylist by genremulti-source fallbacklossless upgrade flowenergy classification
v3

Robustness

upstream de-duplicationescalating searchauto-reconnectbad-file guardnormalized queuedated nightly retrysecrets out of code

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.

SoundMesh is presented here as a generic peer-to-peer network for freely licensed, self-produced audio. The engineering described (self-hosted daemon, REST orchestration, conversion pipeline, library integration, energy classification) is independent of the source and applies to any catalog the user can legitimately access.