feat: loading local songs, basic association

association used to load existing playlists with local files
This commit is contained in:
2026-09-02 14:23:16 +02:00
parent aba98d3122
commit 8a3dd7a583
24 changed files with 542 additions and 113 deletions
+3 -10
View File
@@ -15,16 +15,9 @@ import type {
Song
} from '@/ts/dtype/playlist';
export const addSongList = ( songs: Song[], first: boolean = false ) => {
if ( first ) {
// FIXME: Needs to insert at current index in queue, but where for rawQueue?
// Probably at end if shuffled, else insert into queue, then copy
rawQueue.value = songs.concat( rawQueue.value );
queue.value = songs.concat( queue.value );
} else {
rawQueue.value = rawQueue.value.concat( songs );
queue.value = queue.value.concat( songs );
}
export const addSongList = ( songs: Song[] ) => {
rawQueue.value = rawQueue.value.concat( songs );
queue.value = queue.value.concat( songs );
};
export const clearQueue = () => {
+47 -2
View File
@@ -1,2 +1,47 @@
// TODO: If local files contained, prompt user to select files, then associate based on file names
export const load = () => {};
import {
queue,
rawQueue,
sources
} from '../state';
import type {
AssociationResult
} from '../plugins/interface';
import type {
Playlist
} from '@/ts/dtype/playlist';
import {
openAssociationManager
} from '@/composables/associationManager';
export const load = ( playlist: Playlist ) => {
queue.value = playlist;
rawQueue.value = playlist;
let needToLoadLocalSongs = false;
for ( const song of playlist ) {
if ( song['additional-identifier'] ) {
needToLoadLocalSongs = true;
break;
}
}
const fileLoader = async ( files: FileList ) => {
const associationResults: AssociationResult[] = [];
for ( const song of playlist ) {
const source = sources[song.source]!;
if ( source.loading.requiresLocalFiles === true ) {
associationResults.push( await source.loading.association( files as FileList, song ) );
}
}
return associationResults.filter( val => val.match !== 'exact' );
};
if ( needToLoadLocalSongs ) {
// FIXME: Combine mime types
openAssociationManager( fileLoader, '' );
}
};