1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 12:12:34 +01:00

[deviantart] add 'png' option (#4846)

This commit is contained in:
Mike Fährmann 2024-02-14 01:03:15 +01:00
parent 966c8608e6
commit 9cc4ec2c58
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 36 additions and 2 deletions

View File

@ -1506,6 +1506,17 @@ Description
* ``"manual"``: Disregard ``has_more`` and only stop when a batch of results is empty. * ``"manual"``: Disregard ``has_more`` and only stop when a batch of results is empty.
extractor.deviantart.png
------------------------
Type
``bool``
Default
``false``
Description
Download the PNG version of images
for which an original file download is not available.
extractor.deviantart.public extractor.deviantart.public
--------------------------- ---------------------------
Type Type

View File

@ -43,6 +43,7 @@ class DeviantartExtractor(Extractor):
def _init(self): def _init(self):
self.jwt = self.config("jwt", False) self.jwt = self.config("jwt", False)
self.png = self.config("png", False)
self.flat = self.config("flat", True) self.flat = self.config("flat", True)
self.extra = self.config("extra", False) self.extra = self.config("extra", False)
self.quality = self.config("quality", "100") self.quality = self.config("quality", "100")
@ -65,6 +66,10 @@ class DeviantartExtractor(Extractor):
self.quality = ",q_{}".format(self.quality) self.quality = ",q_{}".format(self.quality)
self.quality_sub = re.compile(r",q_\d+").sub self.quality_sub = re.compile(r",q_\d+").sub
if self.png:
self.png = "-fullview.png?"
self.png_sub = re.compile(r"-fullview\.[a-z0-9]+\?").sub
if self.original != "image": if self.original != "image":
self._update_content = self._update_content_default self._update_content = self._update_content_default
else: else:
@ -345,6 +350,9 @@ class DeviantartExtractor(Extractor):
if self.quality: if self.quality:
content["src"] = self.quality_sub( content["src"] = self.quality_sub(
self.quality, content["src"], 1) self.quality, content["src"], 1)
if self.png:
content["src"] = self.png_sub(
self.png, content["src"], 1)
return content return content

View File

@ -732,8 +732,7 @@ __tests__ = (
"#comment" : "journal", "#comment" : "journal",
"#category": ("", "deviantart", "deviation"), "#category": ("", "deviantart", "deviation"),
"#class" : deviantart.DeviantartDeviationExtractor, "#class" : deviantart.DeviantartDeviationExtractor,
"#pattern" : """text:<!DOCTYPE html> "#pattern" : """text:<!DOCTYPE html>\n""",
""",
"#sha1_url": "d34b2c9f873423e665a1b8ced20fcb75951694a3", "#sha1_url": "d34b2c9f873423e665a1b8ced20fcb75951694a3",
}, },
@ -754,6 +753,22 @@ __tests__ = (
"#count" : 0, "#count" : 0,
}, },
{
"#url" : "https://www.deviantart.com/colibriworkshop/art/Crimson-Pandaren-Phoenix-World-of-Warcraft-630984457",
"#comment" : "'png' option (#4846)",
"#category": ("", "deviantart", "deviation"),
"#class" : deviantart.DeviantartDeviationExtractor,
"#options" : {"png": True, "intermediary": False},
"#sha1_content": "75fb92a820b154c061f7e1f9935260577b2365ec",
"#pattern" : r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com"
r"/f/d86d1faa-37a8-4bcb-b421-53331885d763/dafo6q1-5c4c999a-019e-4845-8c29-6fab2d05c8e8\.jpg"
r"/v1/fill/w_1024,h_1297,q_100,strp"
r"/crimson_pandaren_phoenix_world_of_warcraft_by_colibriworkshop_dafo6q1-fullview\.png"
r"\?token=ey.+",
"extension": "png",
},
{ {
"#url" : "https://deviantart.com/view/904858796/", "#url" : "https://deviantart.com/view/904858796/",
"#comment" : "/view/ URLs", "#comment" : "/view/ URLs",