This project rebuilds the playlist transformer around a simple .env configuration model and a container-friendly workflow. It scans a directory for .m3u files, rewrites each playlist, and either saves a sibling output file or replaces the original in place.
For each playlist, the transformer:
- Normalizes Windows path separators to
/. - Removes lines containing a configured marker.
- Replaces a configured path prefix.
- Applies optional string-for-string replacements.
- Title-cases the third path segment when it is fully uppercase.
- Writes a clean playlist with a fixed header.
Copy .env.example to .env and update the values for your environment.
INPUT_DIR=./files
INITIATOR=C:/Music/
REPLACEMENT=../../music/
KILL_LINE=#EXTINF
HEADER=#EXTM3U
REPLACE_FILE=false
REPLACE_FILE_VALUE=-synology
TARGET_ITEMS=OLD_NAME||LIVE SET
REPLACEMENT_ITEMS=New_Name||Live SetNotes:
INPUT_DIRpoints to the folder containing your.m3ufiles.REPLACE_FILE=falsewrites a new file usingREPLACE_FILE_VALUEas a suffix.REPLACE_FILE=trueoverwrites the original file and ignoresREPLACE_FILE_VALUE.TARGET_ITEMSandREPLACEMENT_ITEMSare optional paired lists separated by||.
Install dependencies:
pip install -r requirements.txtRun the transformer:
python main.py --env-file .envBuild the image:
docker build -t m3u-transform .Run it:
docker run --rm --env-file .env -v "${PWD}/files:/app/files" m3u-transform- Create a local
files/directory for your playlists. - Copy
.env.exampleto.envand setINPUT_DIR=/app/files. - Start the job:
docker compose up --buildpytest