Skip to content

Commit

Permalink
[deviantart] check availability of intermediary URLs (fixes #609)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 21, 2020
1 parent 5607dd3 commit 64bdec8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ def items(self):
if content["src"].startswith("https://images-wixmp-"):
if deviation["index"] <= 790677560:
# https://github.com/r888888888/danbooru/issues/4069
content["src"] = re.sub(
intermediary, count = re.subn(
r"(/f/[^/]+/[^/]+)/v\d+/.*",
r"/intermediary\1", content["src"])
if count and self._check_url(intermediary):
content["src"] = intermediary
if self.quality:
content["src"] = re.sub(
r"q_\d+", self.quality, content["src"])
Expand Down Expand Up @@ -261,6 +263,9 @@ def _update_content_image(self, deviation, content):
if mtype and mtype.startswith("image/"):
content.update(data)

def _check_url(self, url):
return self.request(url, method="HEAD", fatal=False).status_code < 400


class DeviantartUserExtractor(DeviantartExtractor):
"""Extractor for an artist's user profile"""
Expand Down Expand Up @@ -737,8 +742,10 @@ def _extract(self, data):
if src.startswith("https://images-wixmp-"):
if deviation["index"] <= 790677560:
# https://github.com/r888888888/danbooru/issues/4069
src = re.sub(
intermediary, count = re.subn(
r"(/f/[^/]+/[^/]+)/v\d+/.*", r"/intermediary\1", src)
if count and self._check_url(intermediary):
src = intermediary
if self.quality:
src = re.sub(r"q_\d+", self.quality, src)

Expand Down

0 comments on commit 64bdec8

Please sign in to comment.