feat: mirror a lossless library to MP3 for iPod sync
Apple's Music app cannot read FLAC, so getting a lossless library onto an iPod requires a converted copy somewhere. This keeps that copy beside the library on a NAS rather than on a laptop, and keeps it current unattended. Walks a source tree and reproduces it path for path as MP3: tags and cover art carried across, already-MP3 sources copied rather than re-encoded, and mirror files whose source has gone deleted along with any directories they emptied. The source library is never written to. Freshness is tracked by modification time -- an encoded file is stamped with its source's mtime, so a file is stale exactly when the two differ. That keeps runs idempotent without a database that could fall out of step with whatever owns the library, which here is Lidarr. Encodes go to a temporary file and are renamed into place, so an interrupted run cannot leave a truncated MP3 that the next run mistakes for finished work. A lock file in the mirror root prevents overlapping passes. Ships as a Python package with a console script, a container image with a TrueNAS Scale compose file, and a Nix flake providing the package, an overlay and a dev shell. The test suite runs real ffmpeg encodes rather than mocks -- the failures worth catching are in what ffmpeg does with tags, cover art and container formats. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
38f545ac32
commit
177761bb75
@@ -0,0 +1,31 @@
|
||||
# TrueNAS Scale "Custom App" definition.
|
||||
#
|
||||
# Build the image on the NAS first (there is no published image yet):
|
||||
# git clone https://code.emmathe.dev/lyrathorpe/music-mirror
|
||||
# cd music-mirror && docker build -t music-mirror:latest .
|
||||
#
|
||||
# Adjust the two host paths and the user to match your pool. The source is
|
||||
# mounted read-only on purpose: nothing here should ever be able to write to
|
||||
# the lossless library.
|
||||
services:
|
||||
music-mirror:
|
||||
image: music-mirror:latest
|
||||
container_name: music-mirror
|
||||
restart: unless-stopped
|
||||
# The dataset owner, so the mirror is not written as root. `id apps` or the
|
||||
# ownership of the mirror dataset will tell you the right numbers.
|
||||
user: "568:568"
|
||||
environment:
|
||||
MUSIC_MIRROR_SOURCE: /music
|
||||
MUSIC_MIRROR_MIRROR: /mirror
|
||||
# LAME V0 averages about 245 kbps. Use 256 for constant bitrate instead.
|
||||
MUSIC_MIRROR_QUALITY: V0
|
||||
# How long to wait between passes. Lidarr imports are picked up on the
|
||||
# next one.
|
||||
MUSIC_MIRROR_INTERVAL: 6h
|
||||
# Concurrent encodes; defaults to the CPU count. Lower it to leave the
|
||||
# NAS responsive during the first full pass.
|
||||
# MUSIC_MIRROR_JOBS: "4"
|
||||
volumes:
|
||||
- /mnt/tank/media/music:/music:ro
|
||||
- /mnt/tank/media/music-mp3:/mirror
|
||||
Reference in New Issue
Block a user