diff --git a/gallery_dl/extractor/philomena.py b/gallery_dl/extractor/philomena.py index 547ef2c8..201d4d69 100644 --- a/gallery_dl/extractor/philomena.py +++ b/gallery_dl/extractor/philomena.py @@ -10,7 +10,6 @@ from .booru import BooruExtractor from .. import text, exception -import operator class PhilomenaExtractor(BooruExtractor): @@ -24,13 +23,17 @@ class PhilomenaExtractor(BooruExtractor): def _init(self): self.api = PhilomenaAPI(self) - if not self.config("svg", True): - self._file_url = operator.itemgetter("view_url") + self.svg = self.config("svg", True) def _file_url(self, post): - if post["format"] == "svg": - return post["view_url"].rpartition(".")[0] + ".svg" - return post["view_url"] + try: + url = post["representations"]["full"] + except Exception: + url = post["view_url"] + + if self.svg and post["format"] == "svg": + return url.rpartition(".")[0] + ".svg" + return url @staticmethod def _prepare(post): diff --git a/test/results/derpibooru.py b/test/results/derpibooru.py index a9a40b6c..ab83ab0f 100644 --- a/test/results/derpibooru.py +++ b/test/results/derpibooru.py @@ -60,7 +60,7 @@ __tests__ = ( "#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_my+little+pony-colon-+friendship+is+magic_.svg", + "#urls" : "https://derpicdn.net/img/view/2024/4/1/3334658.svg", "#sha1_content": "eec5adf02e2a4fe83b9211c0444d57dc03e21f50", "extension": "svg", diff --git a/test/results/philomena.py b/test/results/philomena.py new file mode 100644 index 00000000..775d2ab3 --- /dev/null +++ b/test/results/philomena.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +from gallery_dl.extractor import philomena + + +__tests__ = ( +{ + "#url" : "philomena:https://manebooru.art/307071", + "#comment" : "'view_url' yields 404 (#6922)", + "#category": ("philomena", "manebooru.art", "post"), + "#class" : philomena.PhilomenaPostExtractor, + "#urls" : "https://static.manebooru.art/img/view/2020/10/27/307071.png", + "#sha1_content": "82c21bfb2675449893fa4b2546546f404019b3c8", + + "date" : "dt:2020-10-27 11:58:40" +}, + +{ + "#url" : "philomena:https://ponerpics.org/images/1", + "#category": ("philomena", "ponerpics.org", "post"), + "#class" : philomena.PhilomenaPostExtractor, + "#urls" : "https://ponerpics.org/img/view/2012/1/2/1.png", + + "date" : "dt:2012-01-02 03:12:33" +}, + +)