[philomena] download 'full' URLs (#6922)

'view_url' URLs sometimes result in 404 errors
This commit is contained in:
Mike Fährmann
2025-02-02 18:23:46 +01:00
parent 4ab9237f1d
commit 6c9b20fe45
3 changed files with 41 additions and 7 deletions

View File

@@ -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):