Add the Import library page and wizard to the web player

Import library sits between Followed and Settings in the account menu and
opens #imports: the sources, the history with statistics and links to the
created playlists, and #imports/N with progress, per-playlist results, a
deleted-playlist notice with Create again, and the entries with status and
playlist filters, search, paging and the candidates of doubtful entries to
choose from. Retry unmatched (with the federated search consent), Cancel,
Delete history and a new Spotify sign-in for waiting imports call the
existing /api/imports endpoints. The page polls every 3 s while an import
runs. It follows the player's views, skeletons, dialogs, switches and
phrase table in English and Russian.

The New import wizard picks a source, then the data export or the Spotify
sign-in, then the playlists: imported ones cannot be selected, similar ones
need an explicit confirmation, and federated search is off until the user
turns it on. A ZIP export is opened in the browser with fflate 0.8.2,
vendored with its MIT licence and served at /vendor/fflate-0.8.2.js only
when an archive is picked. Only Playlist*.json and YourLibrary.json are
extracted; archives over 256 MiB, with more than 2,000 entries, more than
256 playlist files or more than 32 MiB declared for them are refused before
anything is decompressed, and a request over 32 MiB is not sent.

Federated tracks can now be removed from a playlist in edit mode:
DELETE /api/player/tracks/content/playlist checks the owner and records the
existing PlaylistTrackRemoved operation. The body-level dialogs get an
Alpine root, which also makes Get app open again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-26 19:05:30 +02:00
1 parent 4d6a1513d9
commit d275e7326b
21 files changed
+2421 -14

No files matched your search

+11 -4
View File
@@ -101,11 +101,18 @@ its destination for its remaining files.
## Spotify library import
Users start an import from **Import library** in the account menu. The page
lists the available sources, the history of imports with their statistics and
links to the created playlists, and the entries of each 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
("Download your data") without any server configuration. The browser opens the
ZIP archive itself and sends only `Playlist*.json` and `YourLibrary.json`;
listening history and account details never leave it. Before anything is
decompressed the browser refuses archives over 256 MiB, archives with more than
2,000 entries, more than 256 playlist files, or playlist files declaring more
than 32 MiB in total. The server parses the files 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.
+28 -1
View File
@@ -172,7 +172,8 @@ extension; the tests install it into `public`.
The publisher tests (`src/library_import/tests/publisher.rs`) run against the
Device Sync tables of the same schema. They cover source order, repeats, empty
playlists, a second pass that adds nothing, Resync appending at the end, tracks
removed by the user or by a committed but not yet applied operation, deleted
removed by the user or by a committed but not yet applied operation, a
federated track removed in the web player by its content id, deleted
target playlists and recreation, an entry failing after its operation was
recorded, registers written concurrently, deletions from the web and from
another device during a batch, older operations that arrive during a batch,
@@ -189,6 +190,32 @@ requests.
The matcher's reference table (`src/library_import/matcher/tests.rs`) runs
without a database and documents the matching rules case by case.
The import page has browser-store tests and a browser scenario on the rendered
player with isolated API fixtures; neither needs a server or a database:
```bash
node --test tests/library_import.test.cjs
FURU_LIBRARY_IMPORT_RENDER_FIXTURE=1 cargo test library_import::tests::web
node tests/browser-library-import.cjs
```
The store tests unzip real archives with the vendored fflate and cover the
archive limits (size, entries, playlist files and declared sizes, checked
before decompression), the request limit, the selection of repeated, similar
and unavailable playlists, federated consent, polling, the Spotify sign-in
return and removing a federated track from a playlist. The browser scenario
checks the menu order on desktop and mobile, history polling, that only
`Playlist*.json` and `YourLibrary.json` from a ZIP with listening history reach
the server, the wizard, details, a manual choice, Retry unmatched, history
deletion, continuing a Spotify import after a new sign-in, federated track
removal in a playlist and reduced motion. Set `PLAYWRIGHT_MODULE` and
`CHROME_PATH` as for the other browser tests; `FURU_SCREENSHOT_DIR` chooses
where screenshots go (default `target/`).
`src/player/vendor/fflate-0.8.2.min.js` is `umd/index.js` of the npm package
`fflate@0.8.2` (MIT, `src/player/vendor/fflate-LICENSE`), served unchanged at
`/vendor/fflate-0.8.2.js` and loaded only when a user picks an archive.
The Spotify export fixture in `src/library_import/adapters/fixtures/spotify_export/`
is synthetic. Add a fresh anonymized real export next to it before relying on the
parser for a new export format.