Skip to content

Commit

Permalink
extend 'parent>child' categories
Browse files Browse the repository at this point in the history
continuation of ed21908

allow for children to have an arbitrary distance from their parent,
e.g. reddit -> danbooru -> imgur:gallery -> imgur:album
would still be covered by 'reddit>imgur' or even 'danbooru>imgur'
  • Loading branch information
mikf committed Aug 7, 2023
1 parent 089d1a4 commit 3963dbe
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class Job():
"""Base class for Job-types"""
"""Base class for Job types"""
ulog = None

def __init__(self, extr, parent=None):
Expand All @@ -33,15 +33,29 @@ def __init__(self, extr, parent=None):
self.status = 0

cfgpath = []
if parent and parent.extractor.category != extr.category:
cat = "{}>{}".format(
parent.extractor.category, extr.category)
cfgpath.append((cat, extr.subcategory))
cfgpath.append((extr.category, extr.subcategory))
if parent:
if extr.category == parent.extractor.category or \
extr.category in parent.parents:
parents = parent.parents
else:
parents = parent.parents + (parent.extractor.category,)

if parents:
for category in parents:
cat = "{}>{}".format(category, extr.category)
cfgpath.append((cat, extr.subcategory))
cfgpath.append((extr.category, extr.subcategory))
self.parents = parents
else:
self.parents = ()
else:
self.parents = ()

if extr.basecategory:
if not cfgpath:
cfgpath.append((extr.category, extr.subcategory))
cfgpath.append((extr.basecategory, extr.subcategory))

if cfgpath:
extr._cfgpath = cfgpath
extr.config = extr._config_shared
Expand Down

0 comments on commit 3963dbe

Please sign in to comment.