Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deviantart] extract sta.sh URLs from text_content #3366

Merged
merged 3 commits into from
Dec 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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