1.5 KiB
1.5 KiB
YouTube Notification Service – Overview
You need to use an external Website like this one to get the RSS feed ID for a channel.
1. Order of events
- Connect to the database: Establish a connection to the database containing the subscribed YouTube channels.
- Retrieve subscriptions: Fetch all subscribed YouTube RSS feed URLs from the database.
- Fetch RSS feeds: Use
feedparserto query each subscribed feed. - Check for updates: Compare the latest feed entries against the last known entry stored in the database.
- Send notifications: If a new video is found, send its information (
title,body,link,timestamp) to thebackend-apiusing a POST request. - Update database: After successfully sending the notification, update the stored latest video information to prevent duplicate notifications.
- Close database connection: Close the database connection once all subscriptions have been processed.
2. Dependencies
- feedparser: Parse YouTube RSS feeds and extract video information.
- requests: Send HTTP POST requests to the
backend-api. - Database driver: Connect to and query the database.
3. Things to improve once it works
- Handle unavailable RSS feeds without stopping the entire service.
- Handle failed API requests so notifications aren't accidentally marked as processed.
- Log errors and processing information using Python's
loggingmodule. Use a LOG_LEVEL to set it to either debugging or production(info)