Syncing the playlists to disk
-
Hi, the player looks great, but the feature mentioned in the title is a must for me (for non-automatic playlists of course). The use case is the following: I have my collection in a directory, in which there's a folder "playlists". The collection gets synchronized on several devices. Optimally the music player playlists should be synchronized with the playlist folder in the collection. I'd be willing to put in the work to make it happen if I get some pointers as to where/how such a feature would best be integrated.
-
@petko10
The playlists are stored in SQL.
Reloading playlists from files will be a bit tricky to do. The other way, syncing playlists to disk would be easier and makes more sense.
An option for this could be added to the playlist settings. This needs to be done in the Playlist Backend: https://github.com/strawberrymusicplayer/strawberry/blob/master/src/playlist/playlistbackend.cpp
You can see how playlists are saved to file in the Playlist Manager here:
https://github.com/strawberrymusicplayer/strawberry/blob/master/src/playlist/playlistmanager.cppAn easier solution would be that you just create a script that retrieves the playlists from SQL and saves to them to files.
-
Sync playlist to a file would be good. I want to use the player on my computer and put out a playlist and add the playist to my DLNA server so my Streaming box can pick up the playlist as well and i can play what i want and not just some random stuff.
-
That would be a very useful feature for me!
Also it would help to solve the problem I had in: https://github.com/strawberrymusicplayer/strawberry/issues/1403I think it would be nice if you could select the playlists you want to be saved. Like right click on the playlist tab -> Automatically save to file.
-
@jonas any possibility to add this feature - automatically save some/all playlists to disk on edit?
Paired with duplicate detection, this would mean users aren't solely relying on the strawberry database to preserve the sanctity of their playlists.
Thanks!
-
Sync your Strawberry Music Player playlists to disk M3U files with duplicate detection, automatic backups, and smart conflict resolution.
Features
- Duplicate Detection: Find and remove duplicate tracks within playlists
- Exact duplicates (same file added multiple times)
- Optional fuzzy matching (same title/artist, different files)
- Playlist Sync: Export database playlists to M3U files
- Creates timestamped backups before overwriting
- Shows what's added/removed before syncing
- Add-only mode to preserve disk entries
- Recursive subdirectory scanning
- Multiple playlist directory support
- Backup Rotation: Automatically clean up old backup files
- Keep N backups per playlist (default: 3)
- Delete backups older than N days (default: 60)
- Count takes priority (always keeps minimum backups)
- Never-Sync List: Skip utility playlists you don't want exported
- Managed via neversync.txt in your playlist folder
- Interactive prompts to add playlists during review
Requirements
- Python 3.6+ (standard library only, no pip installs needed)
- Linux, macOS, or Windows
Installation
- Save the script to your preferred location, e.g.:
~/.local/share/strawberry/strawberry/strawberry-playlist-sync.py - Make it executable (Linux/macOS):
chmod +x strawberry-playlist-sync.py - Optionally create a desktop shortcut (see below).
Usage
Interactive Mode
./strawberry-playlist-sync.py
Presents a menu to choose between duplicate checking, syncing, and backup cleanup.Command-Line Mode
Dry run (preview changes without writing):
./strawberry-playlist-sync.py -s -p ~/Music/playlists --dry-runDry run with full track details:
./strawberry-playlist-sync.py -s -p ~/Music/playlists --dry-run -vSync playlists to disk:
./strawberry-playlist-sync.py -s -p ~/Music/playlistsSync including subdirectories:
./strawberry-playlist-sync.py -s -p ~/Music/playlists -rCheck for duplicates:
./strawberry-playlist-sync.py -dInclude fuzzy duplicates (same song, different files):
./strawberry-playlist-sync.py -d --fuzzyClean up old backups:
./strawberry-playlist-sync.py -c -n 5 -a 30
(Keep 5 backups, delete those older than 30 days)Run all operations:
./strawberry-playlist-sync.py -d -s -c -p ~/Music/playlistsAutomated mode (no prompts):
./strawberry-playlist-sync.py -s -p ~/Music/playlists -yMultiple Directories
./strawberry-playlist-sync.py -s -p ~/Music/playlists -p /media/usb/playlists
Command-Line Options
┌─────────────────────────┬─────────────────────────────────────────────────┐
│ Option │ Description │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -d, --check-duplicates │ Find and remove duplicate tracks │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ --fuzzy │ Include fuzzy duplicates in check │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -s, --sync │ Sync database playlists to disk │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -c, --cleanup-backups │ Clean up old backup files │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -p, --playlist-dir PATH │ Playlist folder (can be used multiple times) │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -r, --recursive │ Scan subdirectories for M3U files │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ --add-only │ Only add tracks, preserve existing disk entries │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ --db-path PATH │ Path to strawberry.db (auto-detects if not set) │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -n, --keep-count N │ Backups to keep per playlist (default: 3) │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -a, --max-age DAYS │ Max backup age in days (default: 60) │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ --dry-run │ Preview changes without writing │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -v, --verbose │ Show full track details (with --dry-run) │
├─────────────────────────┼─────────────────────────────────────────────────┤
│ -y, --yes │ Skip confirmation prompts │
└─────────────────────────┴─────────────────────────────────────────────────┘
Never-Sync ListTo exclude playlists from syncing (e.g., utility playlists for finding missing metadata):
- During interactive review, when you skip a playlist, you'll be asked if you want to add it to the never-sync list.
- Or manually edit neversync.txt in your playlist folder:
Playlists listed here will be skipped during sync operations.
NoComposerSP
BitrateLessThan129SP
UnratedSPDesktop Shortcut (Linux)
Create a shell script on your desktop:
#!/bin/bash
Strawberry Playlist Sync
~/.local/share/strawberry/strawberry/strawberry-playlist-sync.py -s -p ~/Music/playlists -r
Save as strawberry-playlist-sync.sh and make executable with chmod +x.
Database Locations
The script auto-detects Strawberry's database in these locations:
- Linux: ~/.local/share/strawberry/strawberry/strawberry.db
- macOS: ~/Library/Application Support/Strawberry/strawberry/strawberry.db
- Windows: ~/AppData/Local/strawberry/strawberry/strawberry.db
Use --db-path to specify a custom location.
Notes
- Safe to run with Strawberry open: The script only reads from the database (except for duplicate removal), so syncing while Strawberry is running is fine. For
duplicate removal, close Strawberry first. - Backups: Before overwriting any M3U file, a timestamped backup is created in a backups/ subfolder.
- M3U Format: Uses extended M3U with #EXTINF:seconds,Artist - Title lines.
- Path Handling: Automatically converts database file:// URLs to filesystem paths and handles URL-encoded characters.
License
Public domain / CC0. Use however you like.
Created by me and Claude Code tonight.
- Duplicate Detection: Find and remove duplicate tracks within playlists