Files
Aurora-SpotiRip/endpoints/spotify-download-status_GET.ts
R3ap3r 3178b8f4f7 Aurora SpotiRip desktop and web app
- 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
2026-09-25 23:20:57 -05:00

32 lines
1.2 KiB
TypeScript

import superjson from "superjson";
import type { OutputType } from "./spotify-download-status_GET.schema";
import { appendSetCookies } from "../helpers/spotifyServer";
import { getDownloadJob, jsonError, requireDownloadAccess } from "../helpers/downloadJobs";
export async function handle(request: Request) {
try {
const access = await requireDownloadAccess(request);
if (access.error) return access.error;
const jobId = new URL(request.url).searchParams.get("jobId") || "";
const job = getDownloadJob(jobId, access.userId);
if (!job) return jsonError("This download has expired or does not exist.", 404);
const output: OutputType = {
status: job.status,
done: job.done,
total: job.total,
failed: job.failed,
currentTitle: job.currentTitle,
error: job.error,
fileName: job.fileName,
savedPath: job.savedPath,
};
const headers = new Headers({ "Content-Type": "application/json", "Cache-Control": "no-store" });
appendSetCookies(headers, access.setCookies);
return new Response(superjson.stringify(output), { headers });
} catch (error) {
return jsonError(error instanceof Error ? error.message : "Unable to check the download.", 500);
}
}