From 17c1badb7841eb532c89c086e0c771d0d7c493da Mon Sep 17 00:00:00 2001 From: Bishop Red Date: Thu, 27 Mar 2025 21:34:15 -0600 Subject: [PATCH 1/6] Adding support for the Multi Image Gallery --- gallery_dl/extractor/deviantart.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 200840dd..5b69e380 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -7,10 +7,10 @@ # published by the Free Software Foundation. """Extractors for https://www.deviantart.com/""" - from .common import Extractor, Message from .. import text, util, exception from ..cache import cache, memcache +import json import collections import mimetypes import binascii @@ -1276,7 +1276,30 @@ class DeviantartDeviationExtractor(DeviantartExtractor): deviation = self.api.deviation(uuid) deviation["_page"] = page - return (deviation,) + + _dev_info = text.extr( + page, '\\"deviationExtended\\":', ',\\"deviation\\":', None) + # Clean up escaped quotes + _json_str = re.sub(r'(? 0: + self.filename_fmt = \ + "{category}_{index}_{title}_{num:>02}.{extension}" + deviation["is_downloadable"] = True + deviation["img_count"] = 1 + len(additional_media) + deviation["num"] = 1 + + yield deviation + for index, post in enumerate(additional_media): + uri = post['media']['baseUri'].encode().decode('unicode-escape') + deviation["content"]["src"] = uri + deviation["num"] += 1 + deviation['index'] = post['fileId'] + # Download only works on purchased materials - no way to check + deviation['is_downloadable'] = False + yield deviation class DeviantartScrapsExtractor(DeviantartExtractor): From 3cbb88b4b560cbb8ca28ed22de8ce9669ab101fe Mon Sep 17 00:00:00 2001 From: Bishop Red Date: Thu, 27 Mar 2025 21:40:53 -0600 Subject: [PATCH 2/6] Adding support for the Multi Image Gallery --- gallery_dl/extractor/deviantart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 5b69e380..998758ae 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -1287,7 +1287,7 @@ class DeviantartDeviationExtractor(DeviantartExtractor): if len(additional_media) > 0: self.filename_fmt = \ "{category}_{index}_{title}_{num:>02}.{extension}" - deviation["is_downloadable"] = True + deviation["img_count"] = 1 + len(additional_media) deviation["num"] = 1 From a854d6060e489249e867eb61647da825088c0246 Mon Sep 17 00:00:00 2001 From: Bishop Red Date: Thu, 27 Mar 2025 21:41:46 -0600 Subject: [PATCH 3/6] Removing a test flag (is_downloadable) to true. --- gallery_dl/extractor/deviantart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 998758ae..f48f1f00 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -1290,8 +1290,8 @@ class DeviantartDeviationExtractor(DeviantartExtractor): deviation["img_count"] = 1 + len(additional_media) deviation["num"] = 1 - yield deviation + for index, post in enumerate(additional_media): uri = post['media']['baseUri'].encode().decode('unicode-escape') deviation["content"]["src"] = uri From af23894911bd02e584290136f1f564b668aafbec Mon Sep 17 00:00:00 2001 From: Bishop Red Date: Thu, 27 Mar 2025 21:44:36 -0600 Subject: [PATCH 4/6] Fixing formatting of a line that is too long --- gallery_dl/extractor/deviantart.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index f48f1f00..274304bf 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -1280,7 +1280,8 @@ class DeviantartDeviationExtractor(DeviantartExtractor): _dev_info = text.extr( page, '\\"deviationExtended\\":', ',\\"deviation\\":', None) # Clean up escaped quotes - _json_str = re.sub(r'(? Date: Fri, 28 Mar 2025 17:15:56 +0100 Subject: [PATCH 5/6] [deviantart] update - use 'index_file' for additional file IDs - rename 'img_count' to 'count' - update 'archive_fmt' --- gallery_dl/extractor/deviantart.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 274304bf..3a862c1f 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -7,10 +7,10 @@ # published by the Free Software Foundation. """Extractors for https://www.deviantart.com/""" + from .common import Extractor, Message from .. import text, util, exception from ..cache import cache, memcache -import json import collections import mimetypes import binascii @@ -1282,24 +1282,27 @@ class DeviantartDeviationExtractor(DeviantartExtractor): # Clean up escaped quotes _json_str = re.sub( r'(? 0: - self.filename_fmt = \ - "{category}_{index}_{title}_{num:>02}.{extension}" + if additional_media: + self.filename_fmt = ("{category}_{index}_{index_file}_{title}_" + "{num:>02}.{extension}") + self.archive_fmt = ("g_{_username}_{index}{index_file:?_//}." + "{extension}") - deviation["img_count"] = 1 + len(additional_media) + deviation["index_file"] = 0 + deviation["count"] = 1 + len(additional_media) deviation["num"] = 1 yield deviation for index, post in enumerate(additional_media): - uri = post['media']['baseUri'].encode().decode('unicode-escape') + uri = post["media"]["baseUri"].encode().decode("unicode-escape") deviation["content"]["src"] = uri deviation["num"] += 1 - deviation['index'] = post['fileId'] + deviation["index_file"] = post["fileId"] # Download only works on purchased materials - no way to check - deviation['is_downloadable'] = False + deviation["is_downloadable"] = False yield deviation From 677c1878006ddb5597d28c633bef25c233735409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 28 Mar 2025 17:19:31 +0100 Subject: [PATCH 6/6] [deviantart] add multi-file test --- test/results/deviantart.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/results/deviantart.py b/test/results/deviantart.py index 89f2248e..3d79474a 100644 --- a/test/results/deviantart.py +++ b/test/results/deviantart.py @@ -901,6 +901,25 @@ __tests__ = ( "extension": "png", }, +{ + "#url" : "https://www.deviantart.com/justatest235723/art/1133021832", + "#comment" : "mutliple images (#6653)", + "#category": ("", "deviantart", "deviation"), + "#class" : deviantart.DeviantartDeviationExtractor, + "#archive" : False, + "#pattern" : ( + r"https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-235680f0-7746-485c-9022-6042ab1f4d50\.png\?token=ey.+", + r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-a47549b4-427d-404d-9a39-64cc07c6b5fb\.png", + r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-faac0af6-ef9b-4c49-82af-349ba9f4acf7\.png", + r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/diqkl8o-34396355-d67d-4069-987f-b80f25495635\.png", + ), + + "index" : 1133021832, + "index_file": {0, 810469878, 810469899, 810469922}, + "count" : 4, + "num" : range(1, 4), +}, + { "#url" : "https://deviantart.com/view/904858796/", "#comment" : "/view/ URLs",