summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/newgrounds.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/newgrounds.py')
-rw-r--r--gallery_dl/extractor/newgrounds.py10
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}