From aeeeb474bc9bc272b10709f5aa2ca94147fdf37d Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 20 Nov 2021 14:33:27 +0100 Subject: [PATCH] try /c/ before /user/ when canonicalizing user names especially for /; this returned the wrong channel, if there is both a /c/ and a /user/ with the same id. example: c/BoyBoyProductions => UC_S45UpAYVuc0fYEcHN9BVQ (would be correct) user/BoyBoyProductions => UC2ct7L3mSnprF5o0GAWLzrg (this was selected) --- app/browse/lib.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/browse/lib.py b/app/browse/lib.py index c0c1c89..d5cea44 100644 --- a/app/browse/lib.py +++ b/app/browse/lib.py @@ -33,12 +33,6 @@ def canonicalize_channel(name): if re.fullmatch(r"(UC[A-Za-z0-9_-]{22})", name): return name - # try /user/ (legacy URLs): - xmlfeed = fetch_xml("user", name) - if xmlfeed: - _, _, _, channel_id, _ = parse_xml(xmlfeed) - return channel_id - # get UCID of /c/ (vanity URLs): today = datetime.now(timezone.utc).strftime("%Y%m%d") r = requests.get(f'https://www.youtube.com/c/{name}/about?pbj=1&hl=en_US', headers={ @@ -50,6 +44,12 @@ def canonicalize_channel(name): except: pass + # try /user/ (legacy URLs): + xmlfeed = fetch_xml("user", name) + if xmlfeed: + _, _, _, channel_id, _ = parse_xml(xmlfeed) + return channel_id + # unable to extract: return None -- 2.39.3