fix: Generate feeds for series in addition to podcast #19

Merged
timharek merged 4 commits from bugfix-allow-series into main 2024-04-02 14:27:00 +00:00
2 changed files with 17 additions and 6 deletions
Showing only changes of commit ab5c1b9e56 - Show all commits

View File

@ -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}`;

View File

@ -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",
},
});
}
};