Mandagstrening — Automatic interval playlist creator
This small tool creates a music playlist for interval training from a public Spotify playlist. It downloads or references tracks and builds a timed playlist where each track and pause has configurable durations.
Contents
mandagstrening.py— main scriptrequirements.txt— Python dependencies
Requirements
- Python 3.10 or newer
- ffmpeg (may be required by some audio tools)
Quick setup (Conda / PowerShell)
# create environment (Python 3.10+)
conda create -n mandag-env python=3.10 -y
conda activate mandag-env
# install dependencies
pip install -r requirements.txt
# update yt-dlp separately if needed
pip install yt-dlp --upgrade
# (optional) install ffmpeg using spotdl helper
spotdl --download-ffmpegAlternative (WSL)
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install yt-dlp --upgrade
spotdl --download-ffmpegUsage
Only --playlist is required. All other arguments are optional.
# basic usage (PowerShell)
python mandagstrening.py --playlist "https://open.spotify.com/playlist/1RxwBNjeOjWWWRiMkEpLzG"
# example with extra options
python mandagstrening.py --playlist "https://open.spotify.com/playlist/7g2zKbEbHslqNnO2qbibVz" --sets 1 --playlist_length 12Arguments
--playlist(required) — URL to a public Spotify playlist--delete_folder(flag) — delete temporary files and folders after run--playlist_name(default: "Mandagstrening") — output playlist name--song_duration(int, default: 45) — duration in seconds for each active song segment--pause_duration(int, default: 15) — duration in seconds for pause between songs--sets(int, default: 3) — split the playlist into this many sets--playlist_length(int, default: None) — total number of songs in the final playlist (defaults to the source playlist length)--randomize(flag) — randomize order of songs
Post-run
During execution the script may open media.yaml for you to edit. This file lists each track and an optional start time (in seconds). The default start time is 0. Edit and save media.yaml if you want custom start offsets.
Troubleshooting
- If downloads fail, make sure
yt-dlpis up-to-date (see setup). Runpip install yt-dlp --upgrade. - If audio processing fails, ensure
ffmpegis installed and available in PATH.spotdl --download-ffmpegcan help. - If Spotify playlist is private or region-restricted, the script may not be able to read it. Use a public playlist.
Notes and tips
- If you plan to reuse temporary downloads, run without
--delete_folder. Use--delete_folderto clean up after creating the final playlist.
License / Attribution
- This project uses third-party tools (e.g., yt-dlp, spotdl, ffmpeg). Please follow their licenses and terms of service when using them.