From 6356c9be964fb362fce5bfc9f03e099c000ad830 Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Tue, 6 Dec 2022 20:20:25 +0800 Subject: [PATCH 1/2] [deviantart] extract sta.sh URLs from 'text_content' --- gallery_dl/extractor/deviantart.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 45beddf30d..da513e6cef 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -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 @@ -896,6 +907,13 @@ 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:\n|" + + DeviantartStashExtractor.pattern), + }), # video ("https://www.deviantart.com/chi-u/art/-VIDEO-Brushes-330774593", { "pattern": r"https://wixmp-.+wixmp.com/v/mp4/.+\.720p\.\w+.mp4", From 13d825731e52bff7a0ba2003f31fba893cf46023 Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Wed, 7 Dec 2022 00:32:03 +0800 Subject: [PATCH 2/2] [deviantart] fix test for sta.sh URL extraction Without the 'count' assertion, the test would be essentially useless. --- gallery_dl/extractor/deviantart.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index da513e6cef..7578570941 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -913,6 +913,7 @@ class DeviantartDeviationExtractor(DeviantartExtractor): "options": (("extra", 1),), "pattern": ("text:\n|" + DeviantartStashExtractor.pattern), + "count": 2, }), # video ("https://www.deviantart.com/chi-u/art/-VIDEO-Brushes-330774593", {