fix: Generate feeds for series in addition to podcast #19
|
|
@ -47,6 +47,7 @@ export const nrkRadio = {
|
|||
searchComponents["schemas"]["searchresult"]
|
||||
>(`https://psapi.nrk.no/radio/search/search?q=${query}`);
|
||||
if (status === OK && response) {
|
||||
console.log("res", response.results);
|
||||
return response.results.series?.results;
|
||||
} else {
|
||||
throw `Something went wrong with ${query} - got status ${status}`;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ async function buildFeed(seriesId: string) {
|
|||
|
||||
export const handler = async (_req: Request, ctx: FreshContext): Promise<Response> => {
|
||||
const seriesId = ctx.params.seriesId;
|
||||
try {
|
||||
const feedContent = await buildFeed(seriesId);
|
||||
|
||||
return new Response(feedContent, {
|
||||
|
|
@ -95,4 +96,13 @@ export const handler = async (_req: Request, ctx: FreshContext): Promise<Respons
|
|||
"Content-Type": "application/xml",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return new Response(JSON.stringify({ message: "Could not generate feed" }), {
|
||||
status: 500,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue