mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
e7431b94b8
Implement share-link detection in search (track, queue, album, artist, composer): enqueue tracks/queues without interrupting playback; preview album/artist/composer without switching the active server; queue preview modal with scrollable track list. Based on community PR #551. Co-authored-by: Daniel Wagner <daniel.iuser@icloud.com>
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { apiWithCredentials } from './subsonicClient';
|
|
import type { SubsonicAlbum, SubsonicArtist, SubsonicSong } from './subsonicTypes';
|
|
|
|
export async function getSongWithCredentials(
|
|
serverUrl: string,
|
|
username: string,
|
|
password: string,
|
|
id: string,
|
|
): Promise<SubsonicSong | null> {
|
|
try {
|
|
const data = await apiWithCredentials<{ song: SubsonicSong }>(
|
|
serverUrl,
|
|
username,
|
|
password,
|
|
'getSong.view',
|
|
{ id },
|
|
);
|
|
return data.song ?? null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export async function getAlbumWithCredentials(
|
|
serverUrl: string,
|
|
username: string,
|
|
password: string,
|
|
id: string,
|
|
): Promise<{ album: SubsonicAlbum; songs: SubsonicSong[] }> {
|
|
const data = await apiWithCredentials<{ album: SubsonicAlbum & { song: SubsonicSong[] } }>(
|
|
serverUrl,
|
|
username,
|
|
password,
|
|
'getAlbum.view',
|
|
{ id },
|
|
);
|
|
const { song, ...album } = data.album;
|
|
return { album, songs: song ?? [] };
|
|
}
|
|
|
|
export async function getArtistWithCredentials(
|
|
serverUrl: string,
|
|
username: string,
|
|
password: string,
|
|
id: string,
|
|
): Promise<{ artist: SubsonicArtist; albums: SubsonicAlbum[] }> {
|
|
const data = await apiWithCredentials<{ artist: SubsonicArtist & { album: SubsonicAlbum[] } }>(
|
|
serverUrl,
|
|
username,
|
|
password,
|
|
'getArtist.view',
|
|
{ id },
|
|
);
|
|
const { album, ...artist } = data.artist;
|
|
return { artist, albums: album ?? [] };
|
|
}
|