[deviantart] slight refactor
This commit is contained in:
@@ -1490,25 +1490,19 @@ class DeviantartOAuthAPI():
|
|||||||
"oauth:deviantart' and follow the instructions to "
|
"oauth:deviantart' and follow the instructions to "
|
||||||
"be able to access them.")
|
"be able to access them.")
|
||||||
# "statusid" cannot be used instead
|
# "statusid" cannot be used instead
|
||||||
if results:
|
if results and "deviationid" in results[0]:
|
||||||
if "deviationid" in results[0]:
|
if self.metadata:
|
||||||
if self.metadata:
|
self._metadata(results)
|
||||||
self._metadata(results)
|
if self.folders:
|
||||||
if self.folders:
|
self._folders(results)
|
||||||
self._folders(results)
|
else: # attempt to fix "deleted" deviations
|
||||||
else:
|
for dev in self._shared_content(results):
|
||||||
# attempt to fix "deleted" deviations
|
if not dev["is_deleted"]:
|
||||||
for result in results:
|
continue
|
||||||
for item in result.get("items") or ():
|
patch = self._call(
|
||||||
if "deviation" not in item or \
|
"/deviation/" + dev["deviationid"], fatal=False)
|
||||||
not item["deviation"]["is_deleted"]:
|
if patch:
|
||||||
continue
|
dev.update(patch)
|
||||||
patch = self._call(
|
|
||||||
"/deviation/" +
|
|
||||||
item["deviation"]["deviationid"],
|
|
||||||
fatal=False)
|
|
||||||
if patch:
|
|
||||||
item["deviation"] = patch
|
|
||||||
|
|
||||||
yield from results
|
yield from results
|
||||||
|
|
||||||
@@ -1527,6 +1521,14 @@ class DeviantartOAuthAPI():
|
|||||||
return
|
return
|
||||||
params["offset"] = int(params["offset"]) + len(results)
|
params["offset"] = int(params["offset"]) + len(results)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _shared_content(results):
|
||||||
|
"""Return an iterable of shared deviations in 'results'"""
|
||||||
|
for result in results:
|
||||||
|
for item in result.get("items") or ():
|
||||||
|
if "deviation" in item:
|
||||||
|
yield item["deviation"]
|
||||||
|
|
||||||
def _pagination_list(self, endpoint, params, key="results"):
|
def _pagination_list(self, endpoint, params, key="results"):
|
||||||
result = []
|
result = []
|
||||||
result.extend(self._pagination(endpoint, params, False, key=key))
|
result.extend(self._pagination(endpoint, params, False, key=key))
|
||||||
|
|||||||
Reference in New Issue
Block a user