[philomena] support downloading SVG files (#5643)

pull/5712/head
Mike Fährmann 4 months ago
parent 8fce9ea6d5
commit 9b99d2c886
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1502,6 +1502,19 @@ Description
See `Filters <https://derpibooru.org/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 <https://twibooru.org/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

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

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

@ -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"),

@ -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"),

Loading…
Cancel
Save