[deviantart] remove prefer-public option

All API requests now always use a public token and only switch to
a private token for pagination results if `refresh-token` is set
and less deviations than requested were returned.
This commit is contained in:
Mike Fährmann 2018-07-26 19:43:46 +02:00
parent bb89a1e6d7
commit 5f27cfeff6
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 2 additions and 22 deletions

View File

@ -333,23 +333,6 @@ Description Download full-sized original images if available.
=========== =====
extractor.deviantart.prefer-public
----------------------------------
=========== =====
Type ``bool``
Default ``false``
Description Call API endpoints with a public access token first
and only switch to a private access token if deviations are missing
(i.e. they are only visible to logged in users).
This option only has an effect when using a `refresh token`__
and tries to minimize the amount of API calls with private access
tokens, as they have a much lower rate limit than public ones.
__ extractor.deviantart.refresh-token_
=========== =====
extractor.deviantart.refresh-token
----------------------------------
=========== =====

View File

@ -17,7 +17,6 @@
"deviantart":
{
"refresh-token": null,
"prefer-public": false,
"flat": true,
"journals": "html",
"mature": true,

View File

@ -461,7 +461,6 @@ class DeviantartAPI():
if not isinstance(self.mature, str):
self.mature = "true" if self.mature else "false"
self.prefer_public = extractor.config("prefer-public", False)
self.refresh_token = extractor.config("refresh-token")
self.client_id = extractor.config("client-id", self.CLIENT_ID)
self.client_secret = extractor.config(
@ -604,7 +603,7 @@ class DeviantartAPI():
self.log.warning("%s. Using %ds delay.", msg, 2 ** self.delay)
def _pagination(self, endpoint, params):
public = self.prefer_public
public = True
while True:
data = self._call(endpoint, params, public=public)
if "results" not in data:
@ -612,13 +611,12 @@ class DeviantartAPI():
return
if (public and self.refresh_token and
len(data["results"]) < params["limit"]):
self.log.debug("Repeating API call with private access token")
self.log.debug("Switching to private access token")
public = False
continue
yield from data["results"]
if not data["has_more"]:
return
public = self.prefer_public
params["offset"] = data["next_offset"]
def _pagination_list(self, endpoint, params):