diff --git a/docs/configuration.rst b/docs/configuration.rst index a9a845bc..35856e37 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1502,6 +1502,19 @@ Description See `Filters `_ for details. +extractor.derpibooru.svg +------------------------ +Type + ``bool`` +Default + ``true`` +Description + Download SVG versions of images when available. + + Try to download the ``view_url`` version of these posts + when this option is disabled. + + extractor.deviantart.auto-watch ------------------------------- Type @@ -3762,6 +3775,19 @@ Description See `Filters `__ for details. +extractor.twibooru.svg +---------------------- +Type + ``bool`` +Default + ``true`` +Description + Download SVG versions of images when available. + + Try to download the ``view_url`` version of these posts + when this option is disabled. + + extractor.twitter.ads --------------------- Type diff --git a/gallery_dl/extractor/philomena.py b/gallery_dl/extractor/philomena.py index 339646ff..150efedc 100644 --- a/gallery_dl/extractor/philomena.py +++ b/gallery_dl/extractor/philomena.py @@ -24,8 +24,13 @@ class PhilomenaExtractor(BooruExtractor): def _init(self): self.api = PhilomenaAPI(self) + if not self.config("svg", True): + self._file_url = operator.itemgetter("view_url") - _file_url = operator.itemgetter("view_url") + def _file_url(self, post): + if post["format"] == "svg": + return post["view_url"].rpartition(".")[0] + ".svg" + return post["view_url"] @staticmethod def _prepare(post): diff --git a/gallery_dl/extractor/twibooru.py b/gallery_dl/extractor/twibooru.py index f57f4798..a725a2c6 100644 --- a/gallery_dl/extractor/twibooru.py +++ b/gallery_dl/extractor/twibooru.py @@ -28,8 +28,13 @@ class TwibooruExtractor(BooruExtractor): def _init(self): self.api = TwibooruAPI(self) + if not self.config("svg", True): + self._file_url = operator.itemgetter("view_url") - _file_url = operator.itemgetter("view_url") + def _file_url(self, post): + if post["format"] == "svg": + return post["view_url"].rpartition(".")[0] + ".svg" + return post["view_url"] @staticmethod def _prepare(post): diff --git a/test/results/derpibooru.py b/test/results/derpibooru.py index 278fcaa0..4fe775bb 100644 --- a/test/results/derpibooru.py +++ b/test/results/derpibooru.py @@ -55,6 +55,18 @@ __tests__ = ( "wilson_score" : float, }, +{ + "#url" : "https://derpibooru.org/images/3334658", + "#comment" : "svg (#5643)", + "#category": ("philomena", "derpibooru", "post"), + "#class" : philomena.PhilomenaPostExtractor, + "#urls" : "https://derpicdn.net/img/view/2024/4/1/3334658__safe_alternate+version_artist-colon-jp_derpibooru+exclusive_twilight+sparkle_alicorn_pony_amending+fences_g4_season+5_-dot-svg+available_female_grin_lo.svg", + "#sha1_content": "eec5adf02e2a4fe83b9211c0444d57dc03e21f50", + + "extension": "svg", + "format" : "svg", +}, + { "#url" : "https://derpibooru.org/1", "#category": ("philomena", "derpibooru", "post"), diff --git a/test/results/twibooru.py b/test/results/twibooru.py index ff0919d6..4720309f 100644 --- a/test/results/twibooru.py +++ b/test/results/twibooru.py @@ -51,6 +51,31 @@ __tests__ = ( "wilson_score" : float, }, +{ + "#url" : "https://twibooru.org/523964", + "#comment" : "svg (#5643)", + "#category": ("philomena", "twibooru", "post"), + "#class" : twibooru.TwibooruPostExtractor, + "#urls" : "https://cdn.twibooru.org/img/2020/7/13/523964/full.svg", + "#sha1_content": "15590fe151ff65ef767b409e46dfdf708b339f4d", + + "extension": "svg", + "format" : "svg", +}, + +{ + "#url" : "https://twibooru.org/523964", + "#comment" : "svg (#5643)", + "#category": ("philomena", "twibooru", "post"), + "#class" : twibooru.TwibooruPostExtractor, + "#options" : {"svg": False}, + "#urls" : "https://cdn.twibooru.org/img/2020/7/13/523964/full.png", + "#sha1_content": "f8ff78e6a929a024f8529199f9a600617898d03c", + + "extension": "png", + "format" : "svg", +}, + { "#url" : "https://twibooru.org/search?q=cute", "#category": ("philomena", "twibooru", "search"),