Skip to content

Commit

Permalink
[deviantart] improve handling of statuses
Browse files Browse the repository at this point in the history
- recursively yield statuses
- ignore items with missing or unexpected field(s)
  • Loading branch information
ClosedPort22 committed Jan 19, 2023
1 parent 3b32671 commit c4aeca7
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,16 +786,21 @@ class DeviantartStatusExtractor(DeviantartExtractor):

def deviations(self):
for status in self.api.user_statuses(self.user, self.offset):
for item in status.get("items", ()): # do not trust is_share
# shared deviations/statuses
key = "deviation" if "deviation" in item else "status"
yield item[key].copy()
# assume is_deleted == true means necessary fields are missing
if status["is_deleted"]:
self.log.warning(
"Skipping status %s (deleted)", status.get("statusid"))
continue
yield status
yield from self.status(status)

def status(self, status):
for item in status.get("items", ()): # do not trust is_share
# shared deviations/statuses
if "deviation" in item:
yield item["deviation"].copy()
if "status" in item:
yield from self.status(item["status"].copy())
# assume is_deleted == true means necessary fields are missing
if status["is_deleted"]:
self.log.warning(
"Skipping status %s (deleted)", status.get("statusid"))
return
yield status

def prepare(self, deviation):
if "deviationid" in deviation:
Expand Down

0 comments on commit c4aeca7

Please sign in to comment.