mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[deviantart] re-add 'quality' option and 'intermediary' transform
This commit is contained in:
parent
20d1683c47
commit
0c5d8b1505
@ -1427,6 +1427,19 @@ Description
|
||||
when a `refresh token <extractor.deviantart.refresh-token_>`__ is provided.
|
||||
|
||||
|
||||
extractor.deviantart.quality
|
||||
----------------------------
|
||||
Type
|
||||
``integer``
|
||||
Default
|
||||
``100``
|
||||
Description
|
||||
JPEG quality level of newer images for which
|
||||
an original file download is not available.
|
||||
|
||||
Note: Only has an effect when `deviantart.jwt <extractor.deviantart.jwt_>`__ is disabled.
|
||||
|
||||
|
||||
extractor.deviantart.refresh-token
|
||||
----------------------------------
|
||||
Type
|
||||
|
@ -75,6 +75,7 @@
|
||||
"client-id": null,
|
||||
"client-secret": null,
|
||||
"refresh-token": null,
|
||||
|
||||
"auto-watch": false,
|
||||
"auto-unwatch": false,
|
||||
"comments": false,
|
||||
@ -84,11 +85,13 @@
|
||||
"group": true,
|
||||
"include": "gallery",
|
||||
"journals": "html",
|
||||
"jwt": true,
|
||||
"mature": true,
|
||||
"metadata": false,
|
||||
"original": true,
|
||||
"pagination": "api",
|
||||
"public": true,
|
||||
"quality": 100,
|
||||
"wait-min": 0
|
||||
},
|
||||
"e621":
|
||||
|
@ -45,6 +45,7 @@ class DeviantartExtractor(Extractor):
|
||||
self.jwt = self.config("jwt", True)
|
||||
self.flat = self.config("flat", True)
|
||||
self.extra = self.config("extra", False)
|
||||
self.quality = self.config("quality", "100")
|
||||
self.original = self.config("original", True)
|
||||
self.comments = self.config("comments", False)
|
||||
|
||||
@ -59,6 +60,9 @@ class DeviantartExtractor(Extractor):
|
||||
else:
|
||||
self.unwatch = None
|
||||
|
||||
if self.quality:
|
||||
self.quality = ",q_{}".format(self.quality)
|
||||
|
||||
if self.original != "image":
|
||||
self._update_content = self._update_content_default
|
||||
else:
|
||||
@ -125,6 +129,18 @@ class DeviantartExtractor(Extractor):
|
||||
self._update_content(deviation, content)
|
||||
elif self.jwt:
|
||||
self._update_token(deviation, content)
|
||||
elif content["src"].startswith("https://images-wixmp-"):
|
||||
if deviation["index"] <= 790677560:
|
||||
# https://github.com/r888888888/danbooru/issues/4069
|
||||
intermediary, count = re.subn(
|
||||
r"(/f/[^/]+/[^/]+)/v\d+/.*",
|
||||
r"/intermediary\1", content["src"], 1)
|
||||
if count:
|
||||
deviation["_fallback"] = (content["src"],)
|
||||
content["src"] = intermediary
|
||||
if self.quality:
|
||||
content["src"] = re.sub(
|
||||
r",q_\d+", self.quality, content["src"], 1)
|
||||
|
||||
yield self.commit(deviation, content)
|
||||
|
||||
|
@ -524,7 +524,16 @@ __tests__ = (
|
||||
"#comment" : "wixmp URL rewrite",
|
||||
"#category": ("", "deviantart", "deviation"),
|
||||
"#class" : deviantart.DeviantartDeviationExtractor,
|
||||
"#pattern" : r"https://images-wixmp-\w+\.wixmp\.com/f/[^/]+/[^.]+\.jpg\?token=",
|
||||
"#pattern" : r"https://wixmp-\w+\.wixmp\.com/f/[^/]+/[^.]+\.jpg\?token=",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.deviantart.com/citizenfresh/art/Hverarond-789295466",
|
||||
"#comment" : "wixmp URL rewrite /intermediary/",
|
||||
"#category": ("", "deviantart", "deviation"),
|
||||
"#class" : deviantart.DeviantartDeviationExtractor,
|
||||
"#options" : {"jwt": False},
|
||||
"#pattern" : r"https://images-wixmp-\w+\.wixmp\.com/intermediary/f/[^/]+/[^.]+\.jpg",
|
||||
},
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user