try again

This commit is contained in:
Jesse Bannon 2024-01-08 17:53:24 -08:00
parent 1061570d51
commit a5100d79cb
2 changed files with 15 additions and 3 deletions

View file

@ -404,6 +404,7 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
)
parents = EntryParent.from_entry_dicts(
url=url,
entry_dicts=entry_dicts,
working_directory=self.working_directory,
include_sibling_metadata=include_sibling_metadata,

View file

@ -144,11 +144,16 @@ class EntryParent(BaseEntry):
return self.uid == playlist_id or any(item in child for child in self.parent_children())
@classmethod
def _get_disconnected_root_parent(cls, parents: List["EntryParent"]) -> Optional["EntryParent"]:
def _get_disconnected_root_parent(
cls, url: str, parents: List["EntryParent"]
) -> Optional["EntryParent"]:
"""
Sometimes the root-level parent is disconnected via playlist_ids Find it if it exists.
"""
def _url_matches(parent: "EntryParent"):
return parent.webpage_url in url or url in parent.webpage_url
def _uid_is_uploader_id(parent: "EntryParent"):
return parent.uid == parent.uploader_id
@ -156,7 +161,12 @@ class EntryParent(BaseEntry):
# If more than 1 parent exists, assume the uploader_id is the root parent
if len(top_level_parents) > 1:
top_level_parents = [parent for parent in parents if _uid_is_uploader_id(parent)]
top_level_parents = [
parent for parent in top_level_parents if _uid_is_uploader_id(parent)
]
if len(top_level_parents) > 1:
top_level_parents = [parent for parent in top_level_parents if _url_matches(parent)]
match len(top_level_parents):
case 0:
@ -178,6 +188,7 @@ class EntryParent(BaseEntry):
@classmethod
def from_entry_dicts(
cls,
url: str,
entry_dicts: List[Dict],
working_directory: str,
include_sibling_metadata: bool,
@ -197,7 +208,7 @@ class EntryParent(BaseEntry):
return []
# If a disconnected root parent exists, connect it here
if (root_parent := cls._get_disconnected_root_parent(parents)) is not None:
if (root_parent := cls._get_disconnected_root_parent(url, parents)) is not None:
parents.remove(root_parent)
root_parent._parent_children = parents
parents = [root_parent]