-
Notifications
You must be signed in to change notification settings - Fork 0
Always include official YouTube feeds and preserve channel IDs #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d6dfb7a
e06ca72
c99db9e
8723ad7
ebf51a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ def generate_atom_feed(channel_id: str, channel_name: str, videos: list[dict]) - | |
| return feed | ||
|
|
||
| PATTERNS = [ | ||
| (r"/channel/([a-zA-Z0-9_-]{22})", "channel"), | ||
| (r"/channel/(UC[a-zA-Z0-9_-]{22})", "channel"), | ||
| (r"/c/([a-zA-Z0-9_-]+)", "custom"), | ||
| (r"/user/([a-zA-Z0-9_-]+)", "user"), | ||
| (r"/@([a-zA-Z0-9_-]+)", "handle"), | ||
|
|
@@ -295,15 +295,31 @@ def build_youtube_feed_url(channel_id: str, feed_type: str = None) -> str: | |
| """Build a YouTube RSS feed URL for the given channel ID.""" | ||
| return f"https://www.youtube.com/feeds/videos.xml?channel_id={channel_id}" | ||
|
|
||
|
|
||
|
|
||
| def build_official_feeds(channel_id: str, feed_type: str = "all") -> dict[str, str]: | ||
| """Return official YouTube feed URLs without duplicating identical links.""" | ||
| youtube_feed = build_youtube_feed_url(channel_id, feed_type="all") | ||
| feeds = { | ||
| "youtube": youtube_feed, | ||
| "all": build_youtube_feed_url(channel_id, feed_type="all"), | ||
| "videos": build_youtube_feed_url(channel_id, feed_type="videos"), | ||
| "shorts": build_youtube_feed_url(channel_id, feed_type="shorts"), | ||
| "live": build_youtube_feed_url(channel_id, feed_type="live"), | ||
| "selected": build_youtube_feed_url(channel_id, feed_type=feed_type), | ||
| } | ||
| return feeds | ||
|
coderabbitai[bot] marked this conversation as resolved.
Comment on lines
+300
to
+311
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡
Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| def get_rss_feed(url: str, include_api_endpoints: bool = False, base_url: str = "http://localhost:8080", feed_type: str = "all") -> tuple: | ||
| """Get RSS feed data for a YouTube channel. | ||
|
|
||
| Returns: (youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints) | ||
| Returns: (youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints, official_feeds) | ||
| """ | ||
| channel_id, channel_name = extract_channel_id(url) | ||
|
|
||
| # YouTube RSS URL (supports hidden filtered variants for shorts/live) | ||
| youtube_rss = build_youtube_feed_url(channel_id, feed_type=feed_type) | ||
| official_feeds = build_official_feeds(channel_id, feed_type=feed_type) | ||
| youtube_rss = official_feeds["selected"] | ||
|
|
||
| # Try to get videos from the selected YouTube channel page | ||
| videos = get_channel_videos(channel_id, feed_type=feed_type) | ||
|
|
@@ -337,7 +353,7 @@ def get_rss_feed(url: str, include_api_endpoints: bool = False, base_url: str = | |
| "live_feed": f"{base_url.rstrip('/')}/feed/live/{encoded_url}", | ||
| } | ||
|
|
||
| return youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints | ||
| return youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints, official_feeds | ||
|
|
||
|
|
||
| def main(): | ||
|
|
@@ -383,7 +399,7 @@ def main(): | |
| url = "https://" + url | ||
|
|
||
| try: | ||
| youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints = get_rss_feed( | ||
| youtube_rss, channel_id, channel_name, atom_feed, video_count, invidious_rss, api_endpoints, _ = get_rss_feed( | ||
| url, | ||
| include_api_endpoints=args.include_api_endpoints, | ||
| base_url=args.base_url | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.