[BUGFIX] Fix multiple top-level parents issue (#325)

This commit is contained in:
Jesse Bannon 2022-11-14 23:01:34 -08:00 committed by GitHub
parent 8d154cc242
commit 26b6ed0add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(