forked from Furumi/furumi-web
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:
1 parent
097812a845
commit
ff87d9110d
20 files changed
+4176
-52
No files matched your search
+41
-2
@@ -631,7 +631,7 @@
|
||||
<div class="settings-page">
|
||||
<label class="section-jump">Settings section
|
||||
<select class="search" @change="jumpToSettings($event.target.value)">
|
||||
<option value="access">Access</option><option value="oidc">SSO</option><option value="agent">Import agent</option><option value="similarity">Similarity</option><option value="downloads">Downloads</option><option value="podcasts">Podcasts</option><option value="federation">Federation</option><option value="lastfm">Last.fm</option><option value="developer">Developer</option>
|
||||
<option value="access">Access</option><option value="oidc">SSO</option><option value="agent">Import agent</option><option value="similarity">Similarity</option><option value="downloads">Downloads</option><option value="podcasts">Podcasts</option><option value="federation">Federation</option><option value="lastfm">Last.fm</option><option value="spotify">Spotify import</option><option value="developer">Developer</option>
|
||||
</select>
|
||||
</label>
|
||||
{% include "admin/podcasts.html" %}
|
||||
@@ -1036,6 +1036,39 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel settings-section settings-spotify" id="settings-spotify">
|
||||
<div class="panel-head">
|
||||
<div class="panel-title">
|
||||
<strong>Spotify Import</strong>
|
||||
<span>Optional playlist import through the Spotify Web API</span>
|
||||
</div>
|
||||
<span class="badge" :class="settingsDraft.spotify_client_id ? 'ok' : 'disabled'" x-text="settingsDraft.spotify_client_id ? 'Web API enabled' : 'Data export only'"></span>
|
||||
</div>
|
||||
<div class="settings-grid">
|
||||
<div class="setting-field">
|
||||
<label>
|
||||
<span>Client ID</span>
|
||||
<span class="source-pill" :class="sourceClass('spotify_client_id')" x-text="settingSource('spotify_client_id')"></span>
|
||||
</label>
|
||||
<input x-model="settingsDraft.spotify_client_id" autocomplete="off" spellcheck="false" />
|
||||
<div class="setting-help">Client ID of a Spotify application owned by a Premium account. Authorization uses PKCE, so no client secret is needed. In Development Mode only users on the application's allowlist can sign in. Leave empty to offer only the data export.</div>
|
||||
</div>
|
||||
<div class="setting-field">
|
||||
<label>
|
||||
<span>Redirect URI</span>
|
||||
<span class="source-pill" :class="sourceClass('spotify_redirect_uri')" x-text="settingSource('spotify_redirect_uri')"></span>
|
||||
</label>
|
||||
<input x-model="settingsDraft.spotify_redirect_uri" :placeholder="spotifyCallbackUrl()" autocomplete="off" spellcheck="false" />
|
||||
<div class="setting-help">Optional. Set it when the public address differs from the one this page was opened at. Spotify requires HTTPS; plain HTTP is accepted only for 127.0.0.1.</div>
|
||||
</div>
|
||||
<div class="setting-field settings-wide">
|
||||
<label for="spotify-callback-url">Redirect URI to register in Spotify</label>
|
||||
<input id="spotify-callback-url" type="text" :value="settingsDraft.spotify_redirect_uri || spotifyCallbackUrl()" readonly @click="$el.select()" />
|
||||
<div class="setting-help">Add this exact address to the Redirect URIs of your Spotify application.</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel settings-section settings-lyrics" id="settings-lyrics">
|
||||
<div class="panel-head"><div class="panel-title"><strong>Lyrics</strong><span>LRCLIB enrichment and local lyrics search</span></div></div>
|
||||
<div class="setting-toggle">
|
||||
@@ -2233,7 +2266,9 @@ function adminV2() {
|
||||
download_proxies: [],
|
||||
torrent_proxy_id: '',
|
||||
youtube_proxy_id: '',
|
||||
youtube_cookie_id: ''
|
||||
youtube_cookie_id: '',
|
||||
spotify_client_id: '',
|
||||
spotify_redirect_uri: ''
|
||||
},
|
||||
settingsProbe: { status: 'idle', ok: false },
|
||||
settingsProbeLoading: false,
|
||||
@@ -3106,6 +3141,10 @@ function adminV2() {
|
||||
return `${window.location.origin}/api/player/lastfm/callback`;
|
||||
},
|
||||
|
||||
spotifyCallbackUrl() {
|
||||
return `${window.location.origin}/api/imports/providers/spotify/callback`;
|
||||
},
|
||||
|
||||
settingsProbeBadge() {
|
||||
if (this.settingsProbeLoading) return 'running';
|
||||
if (this.settingsProbe.status === 'ok') return 'ok';
|
||||
|
||||
Reference in new issue
Block a user