Spotify Playlist → M3U Generator

zertcry
2026-02-23T09:57:07Z

Scrapes current Spotify playlist, matches against your library map CSV, generates M3U with optional relative paths

What does this script do?

This userscript adds a panel to Spotify's web player that lets you scrape any playlist and export it as an .m3u file matched against your local music library. It's useful if you want to recreate a Spotify playlist in a local media player like VLC, foobar2000, or MPC-HC using files you already own.

Requirements

Tampermonkey installed in your browser

A library_map.csv file mapping your local audio files (see below)

How to generate your library_map.csv

The script needs a CSV index of your local music library to match Spotify tracks to local files. A companion Python script is available directly in the panel (Download Python script button) — it scans your music folder, reads the metadata tags from each file, and generates the CSV automatically.

Requirements: Python 3 + mutagen (pip install mutagen)

Supported formats: MP3, FLAC, M4A, AAC, OGG, Opus, WMA, WAV, AIFF, APE, WavPack

Just edit the two paths at the top of the script and run it. The CSV will have these columns: abs_path, track_name, artist_name, album_name, filename.

How to use the script

The panel guides you through a one-time 4-step setup. Your settings are saved automatically and survive page refreshes — you only need to go through setup once.

Step 1 — CSV: Download the Python script or a sample CSV to understand the format.

Step 2 — Import: Load your library_map.csv. The library is indexed in memory and saved so it reloads automatically on refresh.

Step 3 — Relative paths (optional): Strip the root part of all paths so the M3U uses relative paths instead of absolute ones. The script will auto-detect a suggested root directly from your CSV.

Step 4 — Scrape & Export: Navigate to the Spotify playlist you want to export and click Start. The script auto-scrolls the page to load all tracks, then lets you download the .m3u file.

Multi-playlist workflow

You can scrape multiple playlists in a row and merge them into a single M3U, or use the 🗑 Clear tracks button between playlists to start fresh. Tracks accumulate across scrapes until you clear them.

Matching logic

Tracks are matched using fuzzy normalization — featured artists, remaster tags, deluxe edition mentions, accents, and punctuation are all stripped before comparing. Matching tries in this order:

1. Title + first artist (exact normalized match)

2. Title + no artist

3. Title only

Tracks not found in your library are still included in the M3U as commented-out # MISSING entries so you can see what wasn't matched.

Notes

Setup (CSV, root path) is fully persisted — refreshing the page always lands you back on step 4

The panel can be minimized by clicking the − button

Only .m3u format is supported (not .m3u8)

The script does not communicate with any external server — everything runs locally in your browser