[BACKEND] Additional filtering on root parent search
This commit is contained in:
parent
75f4a52099
commit
eac521a4a0
1 changed files with 10 additions and 5 deletions
|
|
@ -215,15 +215,20 @@ class EntryParent(BaseEntry):
|
||||||
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(webpage_url: str):
|
def _url_matches(parent: "EntryParent"):
|
||||||
return webpage_url in url or url in webpage_url
|
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
|
||||||
|
|
||||||
top_level_parents = [
|
top_level_parents = [
|
||||||
parent
|
parent for parent in parents if parent.num_children() == 0 and _url_matches(parent)
|
||||||
for parent in parents
|
|
||||||
if parent.num_children() == 0 and _url_matches(parent.webpage_url)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 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)]
|
||||||
|
|
||||||
match len(top_level_parents):
|
match len(top_level_parents):
|
||||||
case 0:
|
case 0:
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue