Import Spotify data exports and optionally playlists from the Spotify Web API

Add the Spotify adapter to the library import. The data export path parses
Playlist*.json and YourLibrary.json sent by the browser, tolerates missing
and unexpected keys, keeps the source order and repeats, and stores episodes,
audiobooks, local files and unreadable entries as unsupported instead of
dropping them. The bundled export fixture is synthetic and must be joined by
an anonymized real export before acceptance.

POST /api/imports/preview lists the playlists of an upload and marks those
already imported or similar to an earlier import; POST /api/imports stores
the selected playlists with every entry in one transaction and starts the
worker. Requests are JSON-only and limited to 32 MiB (413). Re-import is
detected per source playlist: a repeat is refused with 409, and a changed
playlist with the same title needs confirm_similar.

The Spotify Web API is optional and enabled by an administrator's client ID
(and redirect URI behind a proxy) in the settings. Sign-in uses PKCE with the
state, verifier and waiting import kept in the session; access tokens stay
only in an in-memory vault for at most 30 minutes. The worker fetches the
selected playlists one by one, honors Retry-After and backs off on server
errors. A missing or expired token parks the import as needs_reauth; signing
in again with the same account continues the same import and skips the
playlists already fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-26 16:30:07 +02:00
1 parent 097812a845
commit ff87d9110d
20 files changed
+4176 -52

No files matched your search

+23
View File
@@ -99,6 +99,29 @@ completion receipts. Retries and restarts retain the choice, avoid duplicates,
and do not re-add tracks subsequently removed by the user. A started batch keeps
its destination for its remaining files.
## Spotify library import
Spotify playlists and Liked Songs are imported from the account data export
("Download your data") without any server configuration. The browser sends
only `Playlist*.json` and `YourLibrary.json`; the server parses them in memory
and stores the entries of the selected playlists. An import request may not
exceed 32 MiB. Importing a playlist a second time is refused; a playlist with
the same title and changed contents is imported as a new playlist only after
confirmation.
The Spotify Web API is optional. Register an application on a Spotify Premium
account, add the users to its allowlist (Development Mode admits at most five)
and set **Settings → Spotify Import → Client ID** (`FURU_SPOTIFY_CLIENT_ID`).
Register the redirect URI shown there in the application; set
`FURU_SPOTIFY_REDIRECT_URI` when the public address differs from the one the
administration page is opened at. Spotify requires HTTPS, or HTTP for
`127.0.0.1`. Sign-in uses PKCE, so no client secret is stored. Access tokens
stay in server memory for at most 30 minutes and are dropped once the
playlists are fetched. After a restart or an expired token an import waits for
the user to sign in again and then continues without fetching the playlists it
already has. In Development Mode Spotify reads only the user's own and
collaborative playlists; others are imported from the data export.
## Federation
Federation is optional. Independent Furumusic and Furumi players that use the