1. Purpose
MyMP3Collection gives an overview of a collection of audio files kept in ordinary folders on the Mac or on external drives. The app reads the tags, groups tracks into albums, fetches info and covers, plays music and makes playlists.
The ground rule is that the audio files are never copied or changed. The database only stores the path to each file. The single exception is export, where you yourself ask for chosen albums to be copied to another drive.
2. Architecture
Browser ──HTTP:5070──▶ Docker-container «mymp3collection»
gunicorn (1 process, threads ) + Flask
│ │ │
▼ ▼ ▼
data/music.db data/covers/ data/backups/
SQLite (WAL) cover images zip files
Mounted in the container
/music ◀── MUSIC_DIR from .env read only
/host/Users/… ◀── home folder (~) read only
/host/Volumes ◀── external drives read-write (only Eksport_…)
/export ◀── ./eksport in project read-write
Background threads: scanning (mutagen) · fetch info (MusicBrainz, Discogs) · export3. Folders and Docker mounts
| On the Mac | In the container | Access | Used for |
|---|---|---|---|
|
| read only | The main folder. Also used in |
|
| read only | Extra music folders in the home folder |
|
| read-write | Music on external drives, and export. The app only writes to new |
|
| read-write | Export without a USB drive |
|
| read-write | Database, covers and backups |
HOST_PREFIX=/host lets the app translate between container paths and Mac paths, so the paths shown and copied can be pasted straight into Finder. New root folders that overlap an existing one are refused.
The Apple Music folder has extra protection in macOS. Docker Desktop must have Full Disk Access, otherwise the mount fails with “operation not permitted” or the folder looks empty.
4. Scanning
All root folders are walked. Folders the app cannot read, and other file types found, are reported, so you can see why something is missing.
Files with the same size and modification time as last time are skipped. New and changed files are read with
mutagen.Tracks are grouped on
album_key: normalised album title and folder.CD1,Disc 2and similar subfolders belong to the folder above.Covers are taken in the order embedded image, image file in the folder, and finally MusicBrainz or Discogs in the “Fetch info” step.
Files that no longer exist are marked
missingand removed with Clean up. Albums you have edited (locked) are not overwritten.
Supported file types: MP3, M4A, M4P, M4B, FLAC, OGG, Opus, WMA, AAC, AIFF and WAV. Protected M4P files from iTunes are registered but cannot be played in the browser.
5. Info and covers
MusicBrainz: at most one request per second, with a
User-Agentcontaining the contact address from Settings. 503 responses are retried after 2, 4 and 8 seconds.The match must be close enough to the album's artist and title. The original year comes from the release group, and the cover from the Cover Art Archive.
Discogs is used as a fallback when MusicBrainz cannot find the album, and requires a free personal token.
Covers are stored as copies in
data/covers/. The tags in the audio files are never changed.
6. Playback and playlists
Audio is sent straight from the file with Flask's send_file and HTTP Range support, so seeking works without anything being copied. The player sits above the track list and plays on through the album or list.
A playlist can be exported as .m3u with Mac paths, or as JSON:
{
"format": "MyMP3Collection-playlist",
"version": 1,
"name": "Bilturen til hytta",
"description": "Lange strekninger, høy volum",
"track_count": 11,
"duration_seconds": 2853.0,
"tracks": [
{
"position": 1,
"title": "Take On Me",
"artist": "a-ha",
"album": "Hunting High and Low",
"track_number": 1,
"year": 1985,
"duration_seconds": 225.0,
"path": "/Users/ola/Music/a-ha/Hunting High and Low/01 Take On Me.mp3",
"file": "01 Take On Me.mp3"
}
]
}On import each track is found again by its path, or by artist and title if the path does not exist on this computer. Tracks that cannot be found are skipped and counted.
7. Export
/Volumes/USB500/
└── Eksport_2026-11-18/
├── Innhold.txt
├── a-ha/
│ └── Hunting High and Low (1985)/
│ ├── cover.jpg
│ ├── 01 Take On Me.mp3
│ └── …
└── Kaizers Orchestra/
└── Ompa til du dør (2001)/
└── …Before copying, free space and write access are checked. Space for everything plus 1% and 50 MB is required.
Each file is copied to a
.partfile, checked for size and renamed at the end. The modification time is kept.Characters FAT32 and exFAT do not accept are replaced. Multi-disc albums get
CD1/CD2.If the folder already exists, the new one becomes
Eksport_2026-11-18_2. Existing files on the drive are not touched.
8. Data model
A single SQLite file, data/music.db, in WAL mode so pages can be read while the scan writes.
| Table | Content |
|---|---|
| One album per |
| One track per file, unique on |
| Playlists and their tracks, with position. Deleting a track removes it from the lists |
| Export history: destination, folder, number of albums and files, bytes, errors and status |
| Key/value: collection name, owner, extra root folders, Discogs token and MusicBrainz contact address |
9. Backup and moving
A backup is a zip with manifest.json, a consistent copy of music.db and covers/, but never the audio files. Before a restore a safety copy of the current data is made.
Tracks are stored with their container path (/music/…). When MUSIC_DIR on the new computer points to a folder with the same structure, every track is recognised at the next scan, with info, edits and playlists. pakk.sh includes pending WAL changes.
10. HTTP interface
| Route | What it does |
|---|---|
| All albums. View, search, genre and sort as parameters |
| The album page and editing with MusicBrainz and Discogs search |
| Artists and all tracks |
| The audio file, sent straight from its path with Range support (seeking) |
| Start, follow and stop the scan |
| The folder picker and the list of root folders |
| Fetch info and covers for many albums |
| Export to a drive |
| Playlists: create, add, remove, reorder, import |
| Export of a playlist |
| Settings, backup and restore |
11. Source code
| File | Content |
|---|---|
| The Flask app: routes, database, playlists, settings and backup |
| Scanning: tags with mutagen, album grouping, covers from file and folder |
| Lookups in MusicBrainz, Cover Art Archive and Discogs |
| Export: plan, space, safe file names and copying via |
| The pages, the stylesheets ( |
|
|
Dependencies: Flask 3, gunicorn and mutagen. Language and theme work as in MyRecordCollection.