From 26b6ed0add0a2edbbbf132e9fb5b9cafef5c86f1 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Mon, 14 Nov 2022 23:01:34 -0800 Subject: [PATCH] [BUGFIX] Fix multiple top-level parents issue (#325) --- src/ytdl_sub/entries/entry_parent.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ytdl_sub/entries/entry_parent.py b/src/ytdl_sub/entries/entry_parent.py index 7c4f8ff3..d4c10185 100644 --- a/src/ytdl_sub/entries/entry_parent.py +++ b/src/ytdl_sub/entries/entry_parent.py @@ -213,19 +213,23 @@ class EntryParent(BaseEntry): for parent in parents if not parent.child_entries and _url_matches(parent.webpage_url) ] - if len(top_level_parents) == 0: - return None match len(top_level_parents): case 0: return None case 1: return top_level_parents[0] - case _: - raise ValueError( - "Detected multiple top-level parents. " - "Please file an issue on GitHub with the URLs used to produce this error" - ) + case 2: + # Channels can have two of the same .info.json. Handle it here + top0 = top_level_parents[0] + top1 = top_level_parents[1] + if top0.uploader_id == top1.uploader_id: + return top0 if not top0.webpage_url.endswith("/videos") else top1 + + raise ValueError( + "Detected multiple top-level parents. " + "Please file an issue on GitHub with the URLs used to produce this error" + ) @classmethod def from_entry_dicts(