mirror of
https://github.com/ershisan99/podcaster.git
synced 2025-12-16 20:59:26 +00:00
chore: add episodes endpoint to podcasts service, add types
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TopPodcastsResponse } from "./podcasts.types";
|
||||
import { GetEpisodesResponse, GetTopPodcastsResponse } from "./podcasts.types";
|
||||
import { PodcastDTO } from "./podcast.dto";
|
||||
|
||||
class PodcastsService {
|
||||
@@ -8,10 +8,27 @@ class PodcastsService {
|
||||
const response = await fetch(
|
||||
`${this.baseUrl}/us/rss/toppodcasts/limit=100/genre=1310/json`,
|
||||
);
|
||||
const data: TopPodcastsResponse = await response.json();
|
||||
const data: GetTopPodcastsResponse = await response.json();
|
||||
|
||||
return data.feed.entry.map((podcast) => new PodcastDTO(podcast));
|
||||
}
|
||||
|
||||
async getEpisodesByPodcastId(podcastId: string) {
|
||||
const url = new URL(`${this.baseUrl}/lookup`);
|
||||
const params = {
|
||||
id: podcastId,
|
||||
media: "podcast",
|
||||
entity: "podcastEpisode",
|
||||
limit: "20",
|
||||
};
|
||||
url.search = new URLSearchParams(params).toString();
|
||||
|
||||
const response = await fetch(url);
|
||||
const data: GetEpisodesResponse = await response.json();
|
||||
|
||||
//TODO: add dto
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export const podcastsService = new PodcastsService();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface TopPodcastsResponse {
|
||||
export interface GetTopPodcastsResponse {
|
||||
feed: Feed;
|
||||
}
|
||||
|
||||
@@ -162,3 +162,49 @@ export interface Attributes9 {
|
||||
export interface Id2 {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface GetEpisodesResponse {
|
||||
resultCount: number;
|
||||
results: PodcastDetails[];
|
||||
}
|
||||
|
||||
export interface PodcastDetails {
|
||||
wrapperType: string;
|
||||
kind: string;
|
||||
collectionId: number;
|
||||
trackId: number;
|
||||
artistName?: string;
|
||||
collectionName: string;
|
||||
trackName: string;
|
||||
collectionCensoredName?: string;
|
||||
trackCensoredName?: string;
|
||||
collectionViewUrl: string;
|
||||
feedUrl: string;
|
||||
trackViewUrl: string;
|
||||
artworkUrl30?: string;
|
||||
artworkUrl60: string;
|
||||
artworkUrl100?: string;
|
||||
collectionPrice?: number;
|
||||
trackPrice?: number;
|
||||
collectionHdPrice?: number;
|
||||
releaseDate: string;
|
||||
collectionExplicitness?: string;
|
||||
trackExplicitness?: string;
|
||||
trackCount?: number;
|
||||
trackTimeMillis: number;
|
||||
country: string;
|
||||
currency?: string;
|
||||
primaryGenreName?: string;
|
||||
contentAdvisoryRating: string;
|
||||
artworkUrl600: string;
|
||||
genreIds?: string[];
|
||||
closedCaptioning?: string;
|
||||
shortDescription?: string;
|
||||
episodeUrl?: string;
|
||||
episodeGuid?: string;
|
||||
description?: string;
|
||||
artworkUrl160?: string;
|
||||
episodeContentType?: string;
|
||||
episodeFileExtension?: string;
|
||||
previewUrl?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user