fix: Generate feeds for series in addition to podcast #19
|
|
@ -47,6 +47,7 @@ export const nrkRadio = {
|
||||||
searchComponents["schemas"]["searchresult"]
|
searchComponents["schemas"]["searchresult"]
|
||||||
>(`https://psapi.nrk.no/radio/search/search?q=${query}`);
|
>(`https://psapi.nrk.no/radio/search/search?q=${query}`);
|
||||||
if (status === OK && response) {
|
if (status === OK && response) {
|
||||||
|
console.log("res", response.results);
|
||||||
return response.results.series?.results;
|
return response.results.series?.results;
|
||||||
} else {
|
} else {
|
||||||
throw `Something went wrong with ${query} - got status ${status}`;
|
throw `Something went wrong with ${query} - got status ${status}`;
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,21 @@ async function buildFeed(seriesId: string) {
|
||||||
|
|
||||||
export const handler = async (_req: Request, ctx: FreshContext): Promise<Response> => {
|
export const handler = async (_req: Request, ctx: FreshContext): Promise<Response> => {
|
||||||
const seriesId = ctx.params.seriesId;
|
const seriesId = ctx.params.seriesId;
|
||||||
const feedContent = await buildFeed(seriesId);
|
try {
|
||||||
|
const feedContent = await buildFeed(seriesId);
|
||||||
|
|
||||||
return new Response(feedContent, {
|
return new Response(feedContent, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/xml",
|
"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