forked from Furumi/furumi-web
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:
1 parent
4d6a1513d9
commit
d275e7326b
21 files changed
+2421
-14
No files matched your search
@@ -2852,7 +2852,7 @@ document.addEventListener('alpine:init', () => {
|
||||
if (GUEST) return;
|
||||
if (this._hashNav) return;
|
||||
const hash = location.hash || '#artists';
|
||||
if (playerOffline() && (/^#(?:listening|podcasts?|artistfed|releasefed|similar|share)(?:[/?]|$)/.test(hash) ||
|
||||
if (playerOffline() && (/^#(?:listening|podcasts?|imports|artistfed|releasefed|similar|share)(?:[/?]|$)/.test(hash) ||
|
||||
(hash.startsWith('#search?') && new URLSearchParams(hash.slice(8)).get('mode') === 'lyrics'))) {
|
||||
return this.openCollectionView('offline_unavailable', hash, options);
|
||||
}
|
||||
@@ -2877,6 +2877,8 @@ document.addEventListener('alpine:init', () => {
|
||||
return this._navigateFromHash({...options, fromHash:true});
|
||||
} else if (view === 'followed') {
|
||||
this.openCollectionView('followed', '#followed', options);
|
||||
} else if (view === 'imports') {
|
||||
Alpine.store('imports').route(id, params, options);
|
||||
} else if (view === 'artists' && new URLSearchParams(params).get('tab') === 'playlists') {
|
||||
this.openCollectionView('playlists', '#artists?tab=playlists', options);
|
||||
} else if (view === 'artists' && !id) {
|
||||
@@ -6109,19 +6111,29 @@ document.addEventListener('alpine:init', () => {
|
||||
const playlist = this.currentPlaylist();
|
||||
const playlistId = Number(playlist.id);
|
||||
const playlistTrackId = Number(track.playlist_track_id || 0);
|
||||
// Federated tracks have no playlist row; they are removed by content id.
|
||||
const contentId = playlistTrackId ? '' : String(track.content_id || '');
|
||||
const previous = (playlist.tracks || []).slice();
|
||||
if (!playlistTrackId) return;
|
||||
if (!playlistTrackId && !contentId) return;
|
||||
|
||||
const finish = this._startTrackChange(playlistId);
|
||||
playlist.tracks = previous.filter(item => Number(item.playlist_track_id || 0) !== playlistTrackId);
|
||||
playlist.tracks = previous.filter(item => playlistTrackId
|
||||
? Number(item.playlist_track_id || 0) !== playlistTrackId
|
||||
: item.playlist_track_id || item.content_id !== contentId);
|
||||
this._updateListTrackCount(playlistId, playlist.tracks.length);
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/player/playlists/${playlistId}/tracks`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ playlist_track_id: playlistTrackId }),
|
||||
});
|
||||
const res = playlistTrackId
|
||||
? await fetch(`/api/player/playlists/${playlistId}/tracks`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ playlist_track_id: playlistTrackId }),
|
||||
})
|
||||
: await fetch('/api/player/tracks/content/playlist', {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ playlist_id: playlistId, content_id: contentId }),
|
||||
});
|
||||
if (!res.ok) throw new Error('remove failed');
|
||||
await this._refreshAfterTrackChange(playlist, res);
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user