[BUGFIX] Fix multiple top-level parents issue

This commit is contained in:
Jesse Bannon 2022-11-14 22:08:39 -08:00
parent efb8ed5666
commit e859ed1dbb

View file

@ -213,19 +213,23 @@ class EntryParent(BaseEntry):
for parent in parents for parent in parents
if not parent.child_entries and _url_matches(parent.webpage_url) if not parent.child_entries and _url_matches(parent.webpage_url)
] ]
if len(top_level_parents) == 0:
return None
match len(top_level_parents): match len(top_level_parents):
case 0: case 0:
return None return None
case 1: case 1:
return top_level_parents[0] return top_level_parents[0]
case _: case 2:
raise ValueError( # Channels can have two of the same .info.json. Handle it here
"Detected multiple top-level parents. " top0 = top_level_parents[0]
"Please file an issue on GitHub with the URLs used to produce this error" 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 @classmethod
def from_entry_dicts( def from_entry_dicts(