Include show name in episode download error
This commit is contained in:
parent
500f1532b5
commit
0b3d33878c
13
lib/nrk.ts
13
lib/nrk.ts
|
|
@ -1,6 +1,6 @@
|
||||||
import { get, OK } from "https://deno.land/x/kall@v0.1.0/mod.ts";
|
import { get, OK } from "https://deno.land/x/kall@v0.1.0/mod.ts";
|
||||||
import {components as searchComponents} from './nrk-search.ts';
|
import { components as searchComponents } from './nrk-search.ts';
|
||||||
import {components as catalogComponents} from './nrk-catalog.ts';
|
import { components as catalogComponents } from './nrk-catalog.ts';
|
||||||
|
|
||||||
|
|
||||||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never
|
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never
|
||||||
|
|
@ -28,16 +28,17 @@ interface Manifest {
|
||||||
async function withDownloadLink(episode: OriginalEpisode): Promise<Episode> {
|
async function withDownloadLink(episode: OriginalEpisode): Promise<Episode> {
|
||||||
// getting stream link
|
// getting stream link
|
||||||
const [playbackStatus, playbackResponse] = await get<Manifest>(`https://psapi.nrk.no/playback/manifest/podcast/${episode.episodeId}`)
|
const [playbackStatus, playbackResponse] = await get<Manifest>(`https://psapi.nrk.no/playback/manifest/podcast/${episode.episodeId}`)
|
||||||
|
|
||||||
if (playbackStatus === OK && playbackResponse) {
|
if (playbackStatus === OK && playbackResponse) {
|
||||||
return {...episode, url: playbackResponse.playable.assets[0].url};
|
return { ...episode, url: playbackResponse.playable.assets[0].url };
|
||||||
} else {
|
} else {
|
||||||
throw `Error getting downloadLink for ${episode.episodeId}`
|
throw `Error getting downloadLink for ${episode.episodeId}, serie: ${episode.originalTitle}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const nrkRadio = {
|
export const nrkRadio = {
|
||||||
search: async (query: string): Promise<SearchResultList> => {
|
search: async (query: string): Promise<SearchResultList> => {
|
||||||
|
|
||||||
const [status, response] = await get<searchComponents["schemas"]["searchresult"]>(`https://psapi.nrk.no/radio/search/search?q=${query}`);
|
const [status, response] = await get<searchComponents["schemas"]["searchresult"]>(`https://psapi.nrk.no/radio/search/search?q=${query}`);
|
||||||
if (status === OK && response) {
|
if (status === OK && response) {
|
||||||
return response.results.series?.results;
|
return response.results.series?.results;
|
||||||
|
|
@ -69,3 +70,5 @@ export const nrkRadio = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue