diff options
| author | 2024-10-14 03:02:05 -0400 | |
|---|---|---|
| committer | 2024-10-14 03:02:05 -0400 | |
| commit | 0db541f524e1774865efebcbe5653e9ad76ea2e8 (patch) | |
| tree | b0fc6ce19628931f61c43f2dc9ebfd88a4332388 /gallery_dl/extractor/newgrounds.py | |
| parent | 1a457ed68769880ab7760e0746f0cbbd9ca00487 (diff) | |
New upstream version 1.27.6.upstream/1.27.6
Diffstat (limited to 'gallery_dl/extractor/newgrounds.py')
| -rw-r--r-- | gallery_dl/extractor/newgrounds.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gallery_dl/extractor/newgrounds.py b/gallery_dl/extractor/newgrounds.py index dfa1f6e..2928573 100644 --- a/gallery_dl/extractor/newgrounds.py +++ b/gallery_dl/extractor/newgrounds.py @@ -32,6 +32,8 @@ class NewgroundsExtractor(Extractor): self.user_root = "https://{}.newgrounds.com".format(self.user) def _init(self): + self._extract_comment_urls = re.compile( + r'(?:<img |data-smartload-)src="([^"]+)').findall self.flash = self.config("flash", True) fmt = self.config("format") @@ -78,8 +80,7 @@ class NewgroundsExtractor(Extractor): if "_fallback" in post: del post["_fallback"] - for url in text.extract_iter( - post["_comment"], 'data-smartload-src="', '"'): + for url in self._extract_comment_urls(post["_comment"]): post["num"] += 1 post["_index"] = "{}_{:>02}".format( post["index"], post["num"]) @@ -243,9 +244,12 @@ class NewgroundsExtractor(Extractor): url = text.ensure_http_scheme(url) url = url.replace("/medium_views/", "/images/", 1) if text.ext_from_url(url) == "webp": + fallback = [url.replace(".webp", "." + e) + for e in ("jpg", "png", "gif") if e != ext] + fallback.append(url) yield { "image" : url.replace(".webp", "." + ext), - "_fallback": (url,), + "_fallback": fallback, } else: yield {"image": url} |
