[deviantart] improve handling of private deviations (#414)
- don't try to call '/deviation/metadata' with an empty list of deviation ids - print a warning when detecting private deviations without having a 'refresh-token'
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
## 1.10.4 - 2019-09-08
|
## 1.10.4 - 2019-09-08
|
||||||
### Additions
|
### Additions
|
||||||
- Support for
|
- Support for
|
||||||
|
|||||||
@@ -873,6 +873,8 @@ class DeviantartAPI():
|
|||||||
|
|
||||||
def deviation_metadata(self, deviations):
|
def deviation_metadata(self, deviations):
|
||||||
""" Fetch deviation metadata for a set of deviations"""
|
""" Fetch deviation metadata for a set of deviations"""
|
||||||
|
if not deviations:
|
||||||
|
return []
|
||||||
endpoint = "deviation/metadata?" + "&".join(
|
endpoint = "deviation/metadata?" + "&".join(
|
||||||
"deviationids[{}]={}".format(num, deviation["deviationid"])
|
"deviationids[{}]={}".format(num, deviation["deviationid"])
|
||||||
for num, deviation in enumerate(deviations)
|
for num, deviation in enumerate(deviations)
|
||||||
@@ -975,13 +977,18 @@ class DeviantartAPI():
|
|||||||
if "results" not in data:
|
if "results" not in data:
|
||||||
self.log.error("Unexpected API response: %s", data)
|
self.log.error("Unexpected API response: %s", data)
|
||||||
return
|
return
|
||||||
if (public and self.refresh_token and
|
|
||||||
len(data["results"]) < params["limit"]):
|
|
||||||
self.log.debug("Switching to private access token")
|
|
||||||
public = False
|
|
||||||
continue
|
|
||||||
|
|
||||||
if extend:
|
if extend:
|
||||||
|
if public and len(data["results"]) < params["limit"]:
|
||||||
|
if self.refresh_token:
|
||||||
|
self.log.debug("Switching to private access token")
|
||||||
|
public = False
|
||||||
|
continue
|
||||||
|
elif data["has_more"]:
|
||||||
|
self.log.warning(
|
||||||
|
"Private deviations detected! Run 'gallery-dl "
|
||||||
|
"oauth:deviantart' and follow the instructions to "
|
||||||
|
"be able to access them.")
|
||||||
if self.metadata:
|
if self.metadata:
|
||||||
self._metadata(data["results"])
|
self._metadata(data["results"])
|
||||||
if self.folders:
|
if self.folders:
|
||||||
@@ -1003,7 +1010,6 @@ class DeviantartAPI():
|
|||||||
deviations, self.deviation_metadata(deviations)):
|
deviations, self.deviation_metadata(deviations)):
|
||||||
deviation.update(metadata)
|
deviation.update(metadata)
|
||||||
deviation["tags"] = [t["tag_name"] for t in deviation["tags"]]
|
deviation["tags"] = [t["tag_name"] for t in deviation["tags"]]
|
||||||
return deviations
|
|
||||||
|
|
||||||
def _folders(self, deviations):
|
def _folders(self, deviations):
|
||||||
"""Add a list of all containing folders to each deviation object"""
|
"""Add a list of all containing folders to each deviation object"""
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
__version__ = "1.10.4"
|
__version__ = "1.10.5-dev"
|
||||||
|
|||||||
Reference in New Issue
Block a user