feat: implement RSS parsing service and podcast controller for feed ingestion and episode synchronization

This commit is contained in:
Michael committed 2026-04-16 13:55:18 +02:00
1 parent ba376930b0
commit e075434dd7
5 files changed
+102 -16

No files matched your search

@@ -56,6 +56,9 @@ export const subscribe = async (req: Request, res: Response) => {
let podcast = await Podcast.findOne({ rssUrl });
if (!podcast) {
// Parse RSS feed
const feedData = await rssParserService.parseFeed(rssUrl);
const episodes = rssParserService.parseEpisodes(feedData.items, feedData.image?.url || '', rssUrl);
try {
const result = await rssParserService.createPodcastFromRss(rssUrl);
podcast = await Podcast.findById(result.podcast._id);
@@ -146,6 +149,29 @@ export const unsubscribe = async (req: Request, res: Response) => {
}
};
export const syncPodcast = async (req: Request, res: Response) => {
try {
if (!req.user) {
return res.status(401).json({ message: 'Not authenticated' });
}
const { podcastId } = req.params;
const podcast = await Podcast.findById(podcastId);
if (!podcast) {
return res.status(404).json({ message: 'Podcast not found' });
}
console.log(`[Sync] Triggering manual sync for podcast: ${podcast.title} (${podcastId})`);
const result = await rssParserService.syncPodcastEpisodes(podcastId, podcast.rssUrl, true);
res.json(result);
} catch (error: any) {
console.error('Manual sync error:', error);
res.status(500).json({ message: error.message || 'Failed to sync podcast' });
}
};
export const searchPodcasts = async (req: Request, res: Response) => {
try {
const { q, limit = 20, skip = 0 } = req.query;