try again
This commit is contained in:
parent
1061570d51
commit
a5100d79cb
2 changed files with 15 additions and 3 deletions
|
|
@ -404,6 +404,7 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
|
||||||
)
|
)
|
||||||
|
|
||||||
parents = EntryParent.from_entry_dicts(
|
parents = EntryParent.from_entry_dicts(
|
||||||
|
url=url,
|
||||||
entry_dicts=entry_dicts,
|
entry_dicts=entry_dicts,
|
||||||
working_directory=self.working_directory,
|
working_directory=self.working_directory,
|
||||||
include_sibling_metadata=include_sibling_metadata,
|
include_sibling_metadata=include_sibling_metadata,
|
||||||
|
|
|
||||||
|
|
@ -144,11 +144,16 @@ class EntryParent(BaseEntry):
|
||||||
return self.uid == playlist_id or any(item in child for child in self.parent_children())
|
return self.uid == playlist_id or any(item in child for child in self.parent_children())
|
||||||
|
|
||||||
@classmethod
|
@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.
|
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"):
|
def _uid_is_uploader_id(parent: "EntryParent"):
|
||||||
return parent.uid == parent.uploader_id
|
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 more than 1 parent exists, assume the uploader_id is the root parent
|
||||||
if len(top_level_parents) > 1:
|
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):
|
match len(top_level_parents):
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -178,6 +188,7 @@ class EntryParent(BaseEntry):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_entry_dicts(
|
def from_entry_dicts(
|
||||||
cls,
|
cls,
|
||||||
|
url: str,
|
||||||
entry_dicts: List[Dict],
|
entry_dicts: List[Dict],
|
||||||
working_directory: str,
|
working_directory: str,
|
||||||
include_sibling_metadata: bool,
|
include_sibling_metadata: bool,
|
||||||
|
|
@ -197,7 +208,7 @@ class EntryParent(BaseEntry):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# If a disconnected root parent exists, connect it here
|
# 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)
|
parents.remove(root_parent)
|
||||||
root_parent._parent_children = parents
|
root_parent._parent_children = parents
|
||||||
parents = [root_parent]
|
parents = [root_parent]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue