fix: Add fallback if episode is missing

Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
This commit is contained in:
Tim Hårek Andreassen 2024-03-02 18:33:40 +01:00
parent 992057b6f7
commit 8586a208f9
No known key found for this signature in database
GPG Key ID: E59C7734F0E10EB5
1 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,15 @@ export const handler = async (_req: Request, ctx: FreshContext): Promise<Respons
console.log("going to get ep for ", episodeId);
const episode = await nrkRadio.getEpisode(seriesId, episodeId);
if (!episode) {
return new Response(JSON.stringify({ message: `Episode ${episodeId} is missing` }), {
headers: {
"Content-Type": "application/json",
},
status: 500,
});
}
const chapters = toChapters(episode);
const body = {
version: "1.2.0",