AppleSync
Sync public Apple Music playlists into a Qobuz library and generate m3u playlists.
AppleSync:
- reads public Apple Music playlist URLs from a TOML config,
- fetches every track in playlist order (no Apple ID or developer token needed),
- groups the tracks by Apple album and looks each album up on Qobuz (UPC first, then artist/title fuzzy matching, verified by ISRC),
- downloads the full matched albums with the existing
rip(streamrip-go) binary, using rip's own Qobuz login, quality and download database, - scans the downloaded files and writes an extended m3u containing exactly the playlist tracks, in playlist order.
The m3u references the ripped album files; AppleSync does not copy audio files.
Requirements
- Go 1.24+ to build.
rip(streamrip-go) installed and logged into Qobuz on the same host.- A Qobuz subscription that allows the configured quality.
- Optional: beets 2.x with an existing library. Recommended on large libraries; AppleSync queries beets by ISRC and album title instead of walking every directory, and gets the canonical imported file paths.
- Public Apple Music playlists (
pl.…). Private/library/playlists are not supported.
Build
make build
# or
go build -o applesync ./cmd/applesync
Configuration
Copy applesync.example.toml to applesync.toml and edit the paths and
playlists. The example targets pihole@jirachi:
- downloads (rip's staging area):
/home/pihole/music/Full/QOBUZ_MONITOR - final library:
/home/pihole/music/Full - playlists:
/home/pihole/music/Full/Qobuz/Playlists
library_dir is the root the music server sees, including beets/imported
folders like Full/Otta/ASTRA/06 STRANGER.flac. AppleSync prefers files there
and falls back to downloads_dir for albums that have not been imported yet.
If library_dir is omitted it defaults to downloads_dir.
Beets
With beets enabled, AppleSync runs one or two beet ls queries per sync (by
ISRC and by album title) and uses the returned paths/ISRCs as its library
index. It then scans only downloads_dir for albums that have not been imported
yet. If beets is disabled, missing, or fails, AppleSync falls back to scanning
library_dir.
[beets]
enabled = true
binary = "/home/pihole/.local/bin/beet"
Use absolute paths for rip and beet so cron jobs work without a login shell.
Per playlist, mode controls only the m3u:
replace— rebuild the file to contain exactly the playlist tracks.append— keep existing entries and append only tracks whose files are not already listed. Re-running is a no-op.
Downloads are always additive: rip's download database skips albums that are
already present. Use --force to redownload.
Qobuz app id
Qobuz album search needs only the public app id. AppleSync resolves it in this order:
[qobuz].app_idfrom the config,- the
app_idalready bootstrapped into rip's config, - scraping
play.qobuz.com.
No Qobuz password or user token is stored by AppleSync.
Usage
# Match everything and show what would happen (no downloads, no m3u writes)
./applesync sync --dry-run -v
# Full sync with the default config path (./applesync.toml)
./applesync sync
# Only one playlist, append mode
./applesync sync --playlist "indie" --mode append
# Rebuild m3u files from files that are already downloaded
./applesync sync --skip-download
# Ignore cached (including negative) Qobuz matches and look everything up again
./applesync sync --refresh-matches
# Download only the first 3 missing albums (useful for a first test)
./applesync sync --limit-albums 3
# Write a JSON report
./applesync sync --report applesync-report.json
--playlist matches against the configured name and URL and can be repeated.
How files are resolved
If beets is enabled (recommended), AppleSync runs beet ls once for the
playlist ISRCs and once for the album titles. That returns the canonical paths
and ISRCs of imported files without walking the library. It then scans only
downloads_dir for albums that have not been imported yet.
Without beets, AppleSync scans the album folders under library_dir and
downloads_dir and reads tags with github.com/dhowden/tag.
Tracks are matched by:
- exact ISRC (rip writes ISRC tags; beets stores them too),
- normalized artist + title,
- title restricted to the matched album and a matching artist.
Files in library_dir that are outside downloads_dir (the imported copies)
are preferred over rip's staging copies. AppleSync never modifies the beets
library; it only queries it. If a newly ripped album has not been imported yet,
the m3u points into downloads_dir; a later run updates it to the imported path.
Missing tracks
By default (missing = "warn") AppleSync writes all tracks it found and reports
the rest in the summary and optional JSON report. Set missing = "fail" to
leave a playlist's m3u untouched when anything is missing. Tracks that are not
on Qobuz yet (common for new singles) are skipped; the next run retries the
negative match after a week.
Cron
15 5 * * * /home/pihole/.local/bin/applesync sync --config /home/pihole/.config/applesync/config.toml >> /home/pihole/applesync.log 2>&1
A lock file in state_dir prevents overlapping runs.
Notes
- Apple Music and Qobuz access here uses unofficial endpoints. The Apple web token is scraped (same approach as AQTransfer); the Qobuz app id is public.
- The Apple playlist is fetched through the catalog API in pages of 100; album metadata is fetched in batches of 100 tracks, so playlists larger than that work normally.
ripis invoked once per run with a batch file of unique Qobuz album ids.