From 0e2a5e09652151335dfbc343c70f65867623f421 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 22 Nov 2020 10:46:54 +0000 Subject: [PATCH] Convert YT channels into atom-ish links --- newswire.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/newswire.py b/newswire.py index 22beae02..cb497c90 100644 --- a/newswire.py +++ b/newswire.py @@ -406,6 +406,15 @@ def xmlStrToDict(baseDir: str, domain: str, xmlStr: str, return {} +def YTchannelToAtomFeed(url: str) -> str: + """Converts a YouTube channel url into an atom feed url + """ + if 'youtube.com/channel/' not in url: + return url + channelId = url.split('youtube.com/channel/')[1] + return 'https://www.youtube.com/feeds/videos.xml?channel_id=' + channelId + + def getRSS(baseDir: str, domain: str, session, url: str, moderated: bool, mirrored: bool, maxPostsPerSource: int, maxFeedSizeKb: int, @@ -430,6 +439,7 @@ def getRSS(baseDir: str, domain: str, session, url: str, 'Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0' if not session: print('WARN: no session specified for getRSS') + url = YTchannelToAtomFeed(url) try: result = session.get(url, headers=sessionHeaders, params=sessionParams) if result: