With the user's consent and federation enabled, entries that the local
library and known federated tracks do not match wait for resolver stage 3.
It looks up each artist group by its original name, its spelling without
Latin diacritics and, if those find nothing, its collaboration parts, and
decides the entries against the federated tracks of the catalogues.
The new artist_catalogs_bounded in the federation client asks at most 16
owners, a given number at a time, in a JoinSet owned by one task; dropping
the stream aborts the search and every catalogue request. The player's
stream_artist_catalogs keeps its behaviour and shares the owner parsing.
Imports search two groups at a time process-wide, give a group 60 s, retry
failed searches after 2/4/8 s, stop after 500 groups or 30 minutes per pass
and cancel running lookups on cancellation or lease loss. Lost catalogues
are counted in the statistics.
POST /api/imports/{id}/items/{item_id}/match takes a stored candidate of
an ambiguous entry for its owner after checking it again, and queues a
finished import so that the choice is published.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the matcher and the first two resolver stages of the library import.
The matcher is pure: titles are split into a core, featured artists and
version tags, taken from the album title too, so a remaster or concert
album counts like a marker in the track title. Hard tags (live, remix,
edit and similar) must be equal; remaster, mono, stereo, explicit and
clean never match automatically. A match without a comparable duration
needs the same album, and a single candidate is not a match by itself.
Collaborations are split only into known artists, so "Tyler, The Creator"
stays one artist.
The resolve_local phase matches pending entries by artist group against
the library, then against federated tracks this server already knows from
searches and from the owner's synced likes and playlists, and stores
matched, ambiguous (with up to five candidates) or unmatched decisions
under the lease. A local match without a cached content id is hashed with
ensure_local_content_id from agent_storage_dir, so local imports are
publishable with federation disabled. The network is reached only through
a FederationAccess trait and only with the user's consent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Add the library_import subsystem core: migration m_0065 with the import,
playlist, item, publication-receipt and attempt tables, the provider-neutral
import model, the adapter trait and the storage layer.
The library_import job claims imports under a two-minute lease that a
heartbeat renews, checks cancellation between phases and resumes an
interrupted import from its stored phase. Matching and publication phases
are placeholders for the following changes. At boot, imports of the previous
process are requeued; a sweeper starts a worker whenever an import waits
without one, so a worker that stops without a server restart is replaced
once its lease expires.
The /api/imports endpoints list the user's imports, show one import with
its playlists and paged entries, cancel it and delete its history while
keeping the created playlists. Every request is scoped to the owner.
GET /imports redirects to the player view.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>