[deviantart] combine 'png' option with 'quality' (#4846)
"quality": "png" to download PNGs instead og JPEGs
This commit is contained in:
@@ -1506,17 +1506,6 @@ 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
|
||||||
@@ -1533,14 +1522,15 @@ Description
|
|||||||
extractor.deviantart.quality
|
extractor.deviantart.quality
|
||||||
----------------------------
|
----------------------------
|
||||||
Type
|
Type
|
||||||
``integer``
|
* ``integer``
|
||||||
|
* ``string``
|
||||||
Default
|
Default
|
||||||
``100``
|
``100``
|
||||||
Description
|
Description
|
||||||
JPEG quality level of newer images for which
|
JPEG quality level of images for which
|
||||||
an original file download is not available.
|
an original file download is not available.
|
||||||
|
|
||||||
Note: Only has an effect when `deviantart.jwt <extractor.deviantart.jwt_>`__ is disabled.
|
Set this to ``"png"`` to download a PNG version of these images instead.
|
||||||
|
|
||||||
|
|
||||||
extractor.deviantart.refresh-token
|
extractor.deviantart.refresh-token
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ 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")
|
||||||
@@ -63,12 +62,12 @@ class DeviantartExtractor(Extractor):
|
|||||||
self.unwatch = None
|
self.unwatch = None
|
||||||
|
|
||||||
if self.quality:
|
if self.quality:
|
||||||
self.quality = ",q_{}".format(self.quality)
|
if self.quality == "png":
|
||||||
self.quality_sub = re.compile(r",q_\d+").sub
|
self.quality = "-fullview.png?"
|
||||||
|
self.quality_sub = re.compile(r"-fullview\.[a-z0-9]+\?").sub
|
||||||
if self.png:
|
else:
|
||||||
self.png = "-fullview.png?"
|
self.quality = ",q_{}".format(self.quality)
|
||||||
self.png_sub = re.compile(r"-fullview\.[a-z0-9]+\?").sub
|
self.quality_sub = re.compile(r",q_\d+").sub
|
||||||
|
|
||||||
if self.original != "image":
|
if self.original != "image":
|
||||||
self._update_content = self._update_content_default
|
self._update_content = self._update_content_default
|
||||||
@@ -350,9 +349,6 @@ 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
|
||||||
|
|
||||||
|
|||||||
@@ -758,11 +758,11 @@ __tests__ = (
|
|||||||
"#comment" : "'png' option (#4846)",
|
"#comment" : "'png' option (#4846)",
|
||||||
"#category": ("", "deviantart", "deviation"),
|
"#category": ("", "deviantart", "deviation"),
|
||||||
"#class" : deviantart.DeviantartDeviationExtractor,
|
"#class" : deviantart.DeviantartDeviationExtractor,
|
||||||
"#options" : {"png": True, "intermediary": False},
|
"#options" : {"quality": "png", "intermediary": False},
|
||||||
"#sha1_content": "75fb92a820b154c061f7e1f9935260577b2365ec",
|
"#sha1_content": "75fb92a820b154c061f7e1f9935260577b2365ec",
|
||||||
"#pattern" : r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com"
|
"#pattern" : r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com"
|
||||||
r"/f/d86d1faa-37a8-4bcb-b421-53331885d763/dafo6q1-5c4c999a-019e-4845-8c29-6fab2d05c8e8\.jpg"
|
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"/v1/fill/w_1024,h_1297,q_75,strp"
|
||||||
r"/crimson_pandaren_phoenix_world_of_warcraft_by_colibriworkshop_dafo6q1-fullview\.png"
|
r"/crimson_pandaren_phoenix_world_of_warcraft_by_colibriworkshop_dafo6q1-fullview\.png"
|
||||||
r"\?token=ey.+",
|
r"\?token=ey.+",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user