Metadata-Version: 2.4
Name: subsnip
Version: 1.1.0
Summary: Playlist CSV to official 320k MP3s with tags, cover art and synced lyrics
Author: ddddaaaattttoooo
License: MIT
Project-URL: Homepage, https://gitlab.com/ddddaaaattttoooo/subsnip
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: yt-dlp
Requires-Dist: mutagen
Dynamic: license-file

<p align="center"><img src="https://gitlab.com/ddddaaaattttoooo/subsnip/-/raw/main/assets/logo.png" width="128" alt="subsnip logo"></p>

<h1 align="center">subsnip</h1>

<p align="center">
Your playlists on any MP3 player: the official recordings, with proper names, album info, cover art and synced lyrics.
</p>

<p align="center">
<a href="https://gitlab.com/ddddaaaattttoooo/subsnip/-/pipelines"><img src="https://gitlab.com/ddddaaaattttoooo/subsnip/badges/main/pipeline.svg" alt="tests"></a>
<a href="https://pypi.org/project/subsnip/"><img src="https://img.shields.io/pypi/v/subsnip" alt="PyPI"></a>
<img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license">
<img src="https://img.shields.io/badge/python-3.8%2B-blue" alt="Python 3.8+">
<img src="https://img.shields.io/badge/audio-320k%20MP3-blue" alt="320k MP3">
<img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS%20%7C%20Windows-blue" alt="Linux, macOS, Windows">
</p>

<p align="center">
  <a href="https://ko-fi.com/ddddaaaattttoooo"><img src="https://img.shields.io/badge/Support-on%20Ko--fi-FF5E5B?style=for-the-badge&logo=kofi&logoColor=white" alt="Support subsnip on Ko-fi"></a>
  <a href="https://discord.gg/gr4uwUyYTG"><img alt="Join the Discord" src="https://img.shields.io/badge/Join-on%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" /></a>
</p>

> Inspired by [spotDL](https://github.com/spotDL/spotify-downloader), but strict: if subsnip can't confirm a song is the official release, it skips it instead of guessing.

---

```
$ subsnip download ~/Downloads/my_playlist.csv
3 already downloaded, 4 to go
[2/7] Lil Peep - feelz  ok
[3/7] Poshlaya Molly - ШКОЛЬНИК  ok
[5/7] Kino - Пачка сигарет  ok
[4/7] Che - wtf  ok
done
```

---

## Installation

subsnip needs **Python 3.8+**, **FFmpeg** and **Node.js**.

### Python (recommended)

```sh
pip install subsnip
subsnip -h
```

Update with `pip install -U subsnip`. If pip says "externally-managed-environment" (many Linux distros), use `pipx install subsnip` instead. If `subsnip` isn't found afterwards, use `python3 -m subsnip` (Windows: `python -m subsnip`), or add pip's scripts folder to your `PATH`.

**Other options**

- From source:
  ```sh
  git clone https://gitlab.com/ddddaaaattttoooo/subsnip
  cd subsnip
  pip install -r requirements.txt
  python3 subsnip.py -h
  ```

### Installing FFmpeg

FFmpeg converts and tags the audio.

- Windows: `winget install Gyan.FFmpeg`
- macOS: `brew install ffmpeg`
- Linux: your package manager, e.g. `sudo apt install ffmpeg`

### Installing Node.js

yt-dlp uses Node.js to read YouTube pages.

- Windows: `winget install OpenJS.NodeJS`
- macOS: `brew install node`
- Linux: your package manager, e.g. `sudo apt install nodejs`

## Usage

Export your playlist as CSV with [Exportify](https://exportify.net), then:

```sh
subsnip [operation] [CSV] [FOLDER]
```

`FOLDER` defaults to `~/Music/<csv name>`. Run `subsnip -h` for help and `subsnip -V` for the version.

**Supported operations**

- `download`: downloads every song in the playlist, skipping songs you already have.
  - Usage: `subsnip download my_playlist.csv`
  - Option: `--workers N`, songs downloaded at once (default 3)
- `check`: compares every song's tags and cover with the playlist. Changes nothing.
  - Usage: `subsnip check my_playlist.csv`
- `retag`: rewrites tags, cover and lyrics. The audio is untouched.
  - Usage: `subsnip retag my_playlist.csv`
- `clean`: moves songs you removed from the playlist (and their lyrics) to `FOLDER/removed`.
  - Usage: `subsnip clean my_playlist.csv`

### Output

```
~/Music/my_playlist/
├── Artist - Song.mp3
├── Artist - Song.lrc
├── my_playlist.m3u8   playlist in your order
├── failed.txt         songs with no exact match (only if there are any)
└── skip.txt           your own list of songs to skip (optional)
```

Copy the folder to your player. Players with synced lyrics read the `.lrc` files; others show the lyrics embedded in the MP3.

### Skipping songs

Create `skip.txt` in the music folder:

```
# never download this one
Some Artist - Some Song
# use my own file instead (it takes this song's place in the playlist)
Other Artist - Other Song = My Artist - My Version
```

## Matching and Audio Quality

subsnip finds each song in this order and stops at the first exact match:

1. **ISRC**, the code that identifies one exact recording, searched on YouTube Music.
2. **Artist and title** on YouTube Music. Artists written in other alphabets (Cyrillic and more) work too.
3. **The artist's own SoundCloud upload.**

Every match must be an official release by the right artist, within 3 seconds of the playlist's length. Fan uploads, music videos, sped-up edits and live versions are never used. Songs with no exact match go to `failed.txt`.

### Metadata and lyrics

Title, all artists, album, album artist, year, track number (the song's place in your playlist, so players that ignore `.m3u8` files still play in order), ISRC, label, genre, explicit flag and the 640×640 album cover. Lyrics come from [LRCLIB](https://lrclib.net) as a synced `.lrc` file plus lyrics embedded in the MP3. Every song is checked right after download.

### Audio Quality

Everything is saved as **320 kbps MP3**, one quality for the whole library, about 140 MB per hour of music.

> **Note**
> subsnip is for personal use. It downloads from YouTube Music and SoundCloud through [yt-dlp](https://github.com/yt-dlp/yt-dlp) and never touches Spotify's audio or any DRM-protected stream. Only download music you have the right to, and follow the terms of the services you use.

## Troubleshooting

- **A song is in `failed.txt`.** No official upload with the same length was found. That's on purpose: subsnip won't guess. Add your own copy and list it in `skip.txt`.
- **"YouTube rate limit hit".** Wait about an hour and run the same command again. Finished songs are skipped.
- **macOS: SSL certificate errors.** Run "Install Certificates.command" in your Python folder (python.org installs only).
- **Old yt-dlp.** Update with `pip install -U yt-dlp`, or point the `YTDLP_PATH` environment variable at a [nightly build](https://github.com/yt-dlp/yt-dlp-nightly-builds/releases).

**Why a CSV and not a link?** A public playlist page only shows the first 100 songs, and reading playlists directly needs a developer key. Exportify gives the full list with ISRCs, genres and labels in one file.

## Contributing

Found a bug or have an idea? Open an [issue](https://gitlab.com/ddddaaaattttoooo/subsnip/-/issues) or a merge request. Run the tests first:

```sh
python3 test_subsnip.py
```

## Credits

Made by [ddddaaaattttoooo](https://gitlab.com/ddddaaaattttoooo).

Built on [yt-dlp](https://github.com/yt-dlp/yt-dlp), [mutagen](https://github.com/quodlibet/mutagen), [FFmpeg](https://ffmpeg.org), [LRCLIB](https://lrclib.net) and [Exportify](https://exportify.net). Inspired by [spotDL](https://github.com/spotDL/spotify-downloader).

## License

This project is licensed under the [MIT](LICENSE) license.
