Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Sync lyrics for local MP3 and FLAC files with LRCLIB, including recursive scans,
dry runs, diff previews, optional embedding and explicit batch approval (`--yes`).
- Accept the object-shaped profile `avatar` (`{"sources": [...]}`) that Spotify now
returns, reducing it to the largest image URL. Previously it raised and broke every
playlist mutation that resolves the username (for example `create_playlist`).
Expand Down
28 changes: 28 additions & 0 deletions docs/lyrics-sync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Sync lyrics for local music

Install the optional media dependency:

```bash
pip install "spotapi[media]"
```

Point SpotAPI at a local MP3 or FLAC file, an album directory, or the root of your music library. Directories are scanned recursively by default. Start with a dry run to inspect the proposed changes:

```bash
spotapi lyrics-sync ./Music --dry-run
spotapi lyrics-sync ./Music
spotapi lyrics-sync ./Music --recursive --yes
spotapi lyrics-sync ./Music --no-recursive
spotapi lyrics-sync ./Music --output ./Lyrics
spotapi lyrics-sync ./Music --embed
```

The command queries [LRCLIB](https://lrclib.net/) using the title, artist, album (when present), and duration from your audio tags. It does not upload audio, require a Spotify account, or use Spotify's lyrics service. Only use lyrics you have permission to store.

Synced lyrics use `.lrc`; unsynced lyrics use `.txt`. Files are saved beside each track unless `--output` is specified, in which case the original relative directory structure is preserved. Existing lyrics are compared before changes; different lyrics require interactive approval unless `-y` or `--yes` is supplied. Redirected or noninteractive runs keep existing lyrics unless explicitly approved with `--yes`. Diffs are shown even with `--yes`. `--dry-run` never writes files, including when combined with `--yes`. A synced version never gets replaced by plain text. When upgrading a `.txt` file, its existing contents are retained.

`--embed` writes FLAC lyrics and unsynced MP3 lyrics; synced MP3 lyrics are saved as `.lrc` sidecars instead. The audio is staged before replacing the original. The command skips ambiguous filenames and invalid metadata, does not reorganize your music library, and stops when the provider is unavailable or rate limited. Lookups are intentionally sequential and spaced apart to respect LRCLIB's batch-client guidelines.

`--recursive` explicitly enables the default behavior; `--no-recursive` restricts scanning to the immediate directory. These flags do not change single-file behavior. Each run fetches fresh results from LRCLIB, so provider edits can change the proposed lyrics. `Not found` means no acceptable metadata and duration match was returned, not necessarily that the song has no lyrics.

The original `spotapi lyrics` command continues to read entitled Spotify lyrics for a Spotify track.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ nav:
- Accounts and playlists: account.md
- Player controls and events: player.md
- Studio: studio.md
- Local lyrics: lyrics-sync.md
- Reference:
- Python API: reference.md
- Request and retry policy: transport.md
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ dev = [
"ruff>=0.4",
"pytest>=8.0",
"pytest-asyncio>=0.24",
"mutagen>=1.47,<2",
"playwright>=1.55,<2",
]

Expand Down
Loading
Loading