feat: implement podcast discovery and management controllers and services

This commit is contained in:
Michael committed 2026-04-16 14:57:49 +02:00
1 parent 7923f4cf09
commit a993e2d658
11 files changed
+318 -183

No files matched your search

+2 -1
View File
@@ -291,7 +291,8 @@ export const subscribeFromDiscovery = async (req: Request, res: Response) => {
export const getTrendingPodcasts = async (req: Request, res: Response) => {
try {
const limit = Number(req.query.limit) || 20;
const trending = await podcastIndexService.getTrendingPodcasts(limit);
const genre = req.query.genre as string;
const trending = await podcastIndexService.getTrendingPodcasts(limit, genre);
res.json({ source: 'itunes', podcasts: trending, count: trending.length });
} catch (error: any) {
console.error('Trending podcasts error:', error.message);
+5 -3
View File
@@ -77,9 +77,11 @@ export const podcastIndexService = {
.filter((r): r is SearchResult => r !== null);
},
getTrendingPodcasts: async (limit: number = 20): Promise<SearchResult[]> => {
// iTunes official top podcasts RSS (France)
getTrendingPodcasts: async (limit: number = 20, genreId?: string): Promise<SearchResult[]> => {
// iTunes official top podcasts RSS
// Format: https://itunes.apple.com/fr/rss/toppodcasts/limit=X/genre=Y/json
const cap = Math.min(limit, 50);
const genrePath = genreId ? `/genre=${genreId}` : '';
const rssResponse = await axios.get<{
feed: {
entry: Array<{
@@ -89,7 +91,7 @@ export const podcastIndexService = {
'im:image': Array<{ label: string; attributes: { height: string } }>;
}>;
};
}>(`https://itunes.apple.com/fr/rss/toppodcasts/limit=${cap}/json`, {
}>(`https://itunes.apple.com/fr/rss/toppodcasts/limit=${cap}${genrePath}/json`, {
timeout: 10000,
});