diff --git a/docs/configuration.rst b/docs/configuration.rst index b1683f9e..2464745b 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1989,7 +1989,7 @@ Description Setting this option to ``"images"`` only downloads original files if they are images and falls back to preview versions for - everything else (archives, etc.). + everything else (archives, videos, etc.). extractor.deviantart.pagination @@ -2005,6 +2005,19 @@ Description * ``"manual"``: Disregard ``has_more`` and only stop when a batch of results is empty. +extractor.deviantart.previews +----------------------------- +Type + ``bool`` +Default + ``false`` +Description + For non-image files (archives, videos, etc.), + also download the file's preview image. + + Set this option to ``"all"`` to download previews for all files. + + extractor.deviantart.public --------------------------- Type diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index b92f33c1..3686e1be 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -46,6 +46,7 @@ class DeviantartExtractor(Extractor): self.extra = self.config("extra", False) self.quality = self.config("quality", "100") self.original = self.config("original", True) + self.previews = self.config("previews", False) self.intermediary = self.config("intermediary", True) self.comments_avatars = self.config("comments-avatars", False) self.comments = self.comments_avatars or self.config("comments", False) @@ -77,6 +78,11 @@ class DeviantartExtractor(Extractor): else: self._update_content = self._update_content_default + if self.previews == "all": + self.previews_images = self.previews = True + else: + self.previews_images = False + journals = self.config("journals", "html") if journals == "html": self.commit_journal = self._commit_journal_html @@ -209,6 +215,18 @@ class DeviantartExtractor(Extractor): comment["_extractor"] = DeviantartAvatarExtractor yield Message.Queue, url, comment + if self.previews and "preview" in deviation: + preview = deviation["preview"] + deviation["is_preview"] = True + if self.previews_images: + yield self.commit(deviation, preview) + else: + mtype = mimetypes.guess_type( + "a." + deviation["extension"], False)[0] + if mtype and not mtype.startswith("image/"): + yield self.commit(deviation, preview) + del deviation["is_preview"] + if not self.extra: continue diff --git a/test/results/deviantart.py b/test/results/deviantart.py index 9552ebd8..de8359ee 100644 --- a/test/results/deviantart.py +++ b/test/results/deviantart.py @@ -689,6 +689,17 @@ __tests__ = ( "#exception": exception.NotFoundError, }, +{ + "#url" : "https://www.deviantart.com/justatest235723/art/archive-1103129101", + "#comment": "ZIP archive + preview image (#3782)", + "#class" : deviantart.DeviantartDeviationExtractor, + "#options": {"previews": True}, + "#pattern": [ + r"/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/di8rvv1-afe65948-16e1-4eca-b08d-9e6aaa9ed344\.zip", + r"/i/940f2d05-c5eb-4917-8192-7eb6a2d508c6/di8rvv1-bb9d891f-4374-4203-acd3-aea34b29a6a1\.png", + ], +}, + { "#url" : "https://www.deviantart.com/myria-moon/art/Aime-Moi-261986576", "#category": ("", "deviantart", "deviation"),