mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[deviantart] add 'public' option
This commit is contained in:
parent
f5a59c4170
commit
0a7eee3ee0
@ -1372,6 +1372,19 @@ Description
|
||||
* ``"manual"``: Disregard ``has_more`` and only stop when a batch of results is empty.
|
||||
|
||||
|
||||
extractor.deviantart.public
|
||||
---------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``true``
|
||||
Description
|
||||
Use a public access token for API requests.
|
||||
|
||||
Disable this option to *force* using a private token for all requests
|
||||
when a `refresh token <extractor.deviantart.refresh-token_>`__ is provided.
|
||||
|
||||
|
||||
extractor.deviantart.refresh-token
|
||||
----------------------------------
|
||||
Type
|
||||
|
@ -74,6 +74,7 @@
|
||||
{
|
||||
"client-id": null,
|
||||
"client-secret": null,
|
||||
"refresh-token": null,
|
||||
"auto-watch": false,
|
||||
"auto-unwatch": false,
|
||||
"comments": false,
|
||||
@ -86,6 +87,8 @@
|
||||
"mature": true,
|
||||
"metadata": false,
|
||||
"original": true,
|
||||
"pagination": "api",
|
||||
"public": true,
|
||||
"wait-min": 0
|
||||
},
|
||||
"e621":
|
||||
|
@ -320,7 +320,7 @@ class DeviantartExtractor(Extractor):
|
||||
yield url, folder
|
||||
|
||||
def _update_content_default(self, deviation, content):
|
||||
public = "premium_folder_data" not in deviation
|
||||
public = False if "premium_folder_data" in deviation else None
|
||||
data = self.api.deviation_download(deviation["deviationid"], public)
|
||||
content.update(data)
|
||||
|
||||
@ -1284,6 +1284,7 @@ class DeviantartOAuthAPI():
|
||||
self.folders = extractor.config("folders", False)
|
||||
self.metadata = extractor.extra or extractor.config("metadata", False)
|
||||
self.strategy = extractor.config("pagination")
|
||||
self.public = extractor.config("public", True)
|
||||
|
||||
self.client_id = extractor.config("client-id")
|
||||
if self.client_id:
|
||||
@ -1389,7 +1390,7 @@ class DeviantartOAuthAPI():
|
||||
"mature_content": self.mature}
|
||||
return self._pagination_list(endpoint, params=params, key="thread")
|
||||
|
||||
def deviation(self, deviation_id, public=True):
|
||||
def deviation(self, deviation_id, public=None):
|
||||
"""Query and return info about a single Deviation"""
|
||||
endpoint = "/deviation/" + deviation_id
|
||||
deviation = self._call(endpoint, public=public)
|
||||
@ -1399,7 +1400,7 @@ class DeviantartOAuthAPI():
|
||||
self._folders((deviation,))
|
||||
return deviation
|
||||
|
||||
def deviation_content(self, deviation_id, public=True):
|
||||
def deviation_content(self, deviation_id, public=None):
|
||||
"""Get extended content of a single Deviation"""
|
||||
endpoint = "/deviation/content"
|
||||
params = {"deviationid": deviation_id}
|
||||
@ -1412,7 +1413,7 @@ class DeviantartOAuthAPI():
|
||||
self.log.warning("Private Journal")
|
||||
return content
|
||||
|
||||
def deviation_download(self, deviation_id, public=True):
|
||||
def deviation_download(self, deviation_id, public=None):
|
||||
"""Get the original file download (if allowed)"""
|
||||
endpoint = "/deviation/download/" + deviation_id
|
||||
params = {"mature_content": self.mature}
|
||||
@ -1427,7 +1428,7 @@ class DeviantartOAuthAPI():
|
||||
params = {"mature_content": self.mature}
|
||||
return self._call(endpoint, params=params)["metadata"]
|
||||
|
||||
def gallery(self, username, folder_id, offset=0, extend=True, public=True):
|
||||
def gallery(self, username, folder_id, offset=0, extend=True, public=None):
|
||||
"""Yield all Deviation-objects contained in a gallery folder"""
|
||||
endpoint = "/gallery/" + folder_id
|
||||
params = {"username": username, "offset": offset, "limit": 24,
|
||||
@ -1517,11 +1518,14 @@ class DeviantartOAuthAPI():
|
||||
refresh_token_key, data["refresh_token"])
|
||||
return "Bearer " + data["access_token"]
|
||||
|
||||
def _call(self, endpoint, fatal=True, public=True, **kwargs):
|
||||
def _call(self, endpoint, fatal=True, public=None, **kwargs):
|
||||
"""Call an API endpoint"""
|
||||
url = "https://www.deviantart.com/api/v1/oauth2" + endpoint
|
||||
kwargs["fatal"] = None
|
||||
|
||||
if public is None:
|
||||
public = self.public
|
||||
|
||||
while True:
|
||||
if self.delay:
|
||||
self.extractor.sleep(self.delay, "api")
|
||||
@ -1563,7 +1567,7 @@ class DeviantartOAuthAPI():
|
||||
return data
|
||||
|
||||
def _pagination(self, endpoint, params,
|
||||
extend=True, public=True, unpack=False, key="results"):
|
||||
extend=True, public=None, unpack=False, key="results"):
|
||||
warn = True
|
||||
while True:
|
||||
data = self._call(endpoint, params=params, public=public)
|
||||
|
Loading…
Reference in New Issue
Block a user