diff options
| author | 2024-12-08 20:34:39 -0500 | |
|---|---|---|
| committer | 2024-12-08 20:34:39 -0500 | |
| commit | 955a18e4feea86fdb35e531a00304e00d037652c (patch) | |
| tree | 06060068ebe725be4294758b2caca3e2491ef4f0 /gallery_dl/extractor/zerochan.py | |
| parent | 402872c8ca0118f5ed9c172d3c11dac90dd41c37 (diff) | |
| parent | f6877087773089220d68288d055276fca6c556d4 (diff) | |
Update upstream source from tag 'upstream/1.28.1'
Update to upstream version '1.28.1'
with Debian dir f1535f052953f6a9195352a951ec8dd121144a27
Diffstat (limited to 'gallery_dl/extractor/zerochan.py')
| -rw-r--r-- | gallery_dl/extractor/zerochan.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gallery_dl/extractor/zerochan.py b/gallery_dl/extractor/zerochan.py index f9b1a7f..4c4fb3a 100644 --- a/gallery_dl/extractor/zerochan.py +++ b/gallery_dl/extractor/zerochan.py @@ -145,6 +145,14 @@ class ZerochanTagExtractor(ZerochanExtractor): self.posts = self.posts_api self.session.headers["User-Agent"] = util.USERAGENT + exts = self.config("extensions") + if exts: + if isinstance(exts, str): + exts = exts.split(",") + self.exts = exts + else: + self.exts = ("jpg", "png", "webp", "gif") + def metadata(self): return {"search_tags": text.unquote( self.search_tag.replace("+", " "))} @@ -194,8 +202,6 @@ class ZerochanTagExtractor(ZerochanExtractor): "p" : self.page_start, } - static = "https://static.zerochan.net/.full." - while True: response = self.request(url, params=params, allow_redirects=False) @@ -221,15 +227,20 @@ class ZerochanTagExtractor(ZerochanExtractor): yield post else: for post in posts: - base = static + str(post["id"]) - post["file_url"] = base + ".jpg" - post["_fallback"] = (base + ".png",) + urls = self._urls(post) + post["file_url"] = next(urls) + post["_fallback"] = urls yield post if not data.get("next"): return params["p"] += 1 + def _urls(self, post, static="https://static.zerochan.net/.full."): + base = static + str(post["id"]) + "." + for ext in self.exts: + yield base + ext + class ZerochanImageExtractor(ZerochanExtractor): subcategory = "image" |
