fix --range causing crashes (#4557)

regression caused by a383eca7
pull/4571/head
Mike Fährmann 1 year ago
parent 3528974459
commit 2cd801232b
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -39,6 +39,7 @@ class DeviantartExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self, match)
self.user = match.group(1) or match.group(2)
self.offset = 0
def _init(self):
self.flat = self.config("flat", True)
@ -48,7 +49,6 @@ class DeviantartExtractor(Extractor):
self.api = DeviantartOAuthAPI(self)
self.group = False
self.offset = 0
self._premium_cache = {}
unwatch = self.config("auto-unwatch")
@ -445,6 +445,8 @@ class DeviantartUserExtractor(DeviantartExtractor):
def initialize(self):
pass
skip = Extractor.skip
def items(self):
base = "{}/{}/".format(self.root, self.user)
return self._dispatch_extractors((

@ -28,9 +28,9 @@ class FuraffinityExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self, match)
self.user = match.group(1)
self.offset = 0
def _init(self):
self.offset = 0
self.external = self.config("external", False)
if self.config("descriptions") == "html":
@ -295,6 +295,8 @@ class FuraffinityUserExtractor(FuraffinityExtractor):
def initialize(self):
pass
skip = Extractor.skip
def items(self):
base = "{}/{{}}/{}/".format(self.root, self.user)
return self._dispatch_extractors((

@ -106,16 +106,15 @@ class Job():
"current_git_head": util.git_head()
}
# predicates
self.pred_url = self._prepare_predicates("image", True)
self.pred_queue = self._prepare_predicates("chapter", False)
def run(self):
"""Execute or run the job"""
extractor = self.extractor
log = extractor.log
msg = None
self._init()
# sleep before extractor start
sleep = util.build_duration_func(
extractor.config("sleep-extractor"))
if sleep:
@ -201,6 +200,11 @@ class Job():
if self.kwdict:
kwdict.update(self.kwdict)
def _init(self):
self.extractor.initialize()
self.pred_url = self._prepare_predicates("image", True)
self.pred_queue = self._prepare_predicates("chapter", False)
def _prepare_predicates(self, target, skip=True):
predicates = []
@ -810,6 +814,8 @@ class DataJob(Job):
self.filter = dict.copy if private else util.filter_dict
def run(self):
self._init()
extractor = self.extractor
sleep = util.build_duration_func(
extractor.config("sleep-extractor"))

@ -37,7 +37,7 @@ __tests__ = (
"#category": ("", "deviantart", "gallery"),
"#class" : deviantart.DeviantartGalleryExtractor,
"#pattern" : r"https://(images-)?wixmp-[^.]+\.wixmp\.com/f/.+/.+\.(jpg|png)\?token=.+",
"#count" : ">= 30",
"#count" : ">= 38",
"allows_comments" : bool,
"author" : {
@ -82,6 +82,17 @@ __tests__ = (
"username" : "shimoda7",
},
{
"#url" : "https://www.deviantart.com/shimoda7/gallery/",
"#comment" : "range/skip (#4557)",
"#category": ("", "deviantart", "gallery"),
"#class" : deviantart.DeviantartGalleryExtractor,
"#options" : {"original": False},
"#pattern" : r"https://images-wixmp-[0-9a-f]+\.wixmp\.com/f/0e474835-ec35-4937-b647-b6830ed58bd1/d2idul-6158ded2-37ac-413d-802e-0689f0f020ad\.jpg\?token=[\w.]+",
"#range" : "38-",
"#count" : 1,
},
{
"#url" : "https://www.deviantart.com/yakuzafc/gallery",
"#comment" : "group",

@ -206,6 +206,7 @@ class ResultJob(job.DownloadJob):
self.extractor.filename_fmt).format_map
def run(self):
self._init()
for msg in self.extractor:
self.dispatch(msg)

Loading…
Cancel
Save