Skip to content

Commit

Permalink
Merge pull request #3366 from ClosedPort22/da-extra-stash
Browse files Browse the repository at this point in the history
[deviantart] extract sta.sh URLs from `text_content`
  • Loading branch information
mikf authored Dec 17, 2022
2 parents f36cbb3 + bf3fd59 commit dd6eeb4
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,20 @@ def items(self):
deviation["_journal"] = journal["html"]
yield self.commit_journal(deviation, journal)

if self.extra:
txt = (deviation.get("description", "") +
deviation.get("_journal", ""))
if not self.extra:
continue

# ref: https://www.deviantart.com
# /developers/http/v1/20210526/object/editor_text
# the value of "features" is a JSON string with forward
# slashes escaped
text_content = \
deviation["text_content"]["body"]["features"].replace(
"\\/", "/") if "text_content" in deviation else None
for txt in (text_content, deviation.get("description"),
deviation.get("_journal")):
if txt is None:
continue
for match in DeviantartStashExtractor.pattern.finditer(txt):
url = text.ensure_http_scheme(match.group(0))
deviation["_extractor"] = DeviantartStashExtractor
Expand Down Expand Up @@ -896,6 +907,14 @@ class DeviantartDeviationExtractor(DeviantartExtractor):
"range": "2-",
"count": 4,
}),
# sta.sh URL from deviation["text_content"]["body"]["features"]
(("https://www.deviantart.com"
"/cimar-wildehopps/art/Honorary-Vixen-859809305"), {
"options": (("extra", 1),),
"pattern": ("text:<!DOCTYPE html>\n|" +
DeviantartStashExtractor.pattern),
"count": 2,
}),
# journal
("https://www.deviantart.com/shimoda7/journal/ARTility-583755752", {
"url": "d34b2c9f873423e665a1b8ced20fcb75951694a3",
Expand Down

0 comments on commit dd6eeb4

Please sign in to comment.