- Spotify playlist, library, album and artist browsing with in-app playback - Song, playlist and album downloads via spotdl with YouTube and Bandcamp fallbacks - Electron desktop app (castLabs Widevine) with a permanent sidebar layout - Linux and Windows packaging scripts
28 lines
838 B
TypeScript
28 lines
838 B
TypeScript
import superjson from "superjson";
|
|
|
|
export type OutputType = {
|
|
status: "running" | "ready" | "failed";
|
|
done: number;
|
|
total: number;
|
|
failed: number;
|
|
currentTitle?: string;
|
|
error?: string;
|
|
fileName?: string;
|
|
savedPath?: string;
|
|
};
|
|
|
|
export async function getSpotifyDownloadStatus(jobId: string): Promise<OutputType> {
|
|
const response = await fetch(`/_api/spotify-download-status?jobId=${encodeURIComponent(jobId)}`, {
|
|
cache: "no-store",
|
|
});
|
|
if (!response.ok) {
|
|
const parsed = (await response.json().catch(() => ({}))) as { error?: string };
|
|
throw new Error(parsed.error || "Unable to check the download.");
|
|
}
|
|
return superjson.parse<OutputType>(await response.text());
|
|
}
|
|
|
|
export function spotifyDownloadFileUrl(jobId: string) {
|
|
return `/_api/spotify-download-file?jobId=${encodeURIComponent(jobId)}`;
|
|
}
|