Skip to content

Commit

Permalink
[deviantart] misc improvements to status extractor
Browse files Browse the repository at this point in the history
- relax regex pattern
- handle invalid 'items' field
- add a test for shared sta.sh item

Co-authored-by: Mike Fährmann <[email protected]>
  • Loading branch information
ClosedPort22 and mikf committed Jan 21, 2023
1 parent 013733c commit 597b892
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ class DeviantartStatusExtractor(DeviantartExtractor):
directory_fmt = ("{category}", "{username}", "Status")
filename_fmt = "{category}_{index}_{title}_{date}.{extension}"
archive_fmt = "S_{_username}_{index}.{extension}"
pattern = BASE_PATTERN + r"/posts/statuses/?(?:\?.*)?$"
pattern = BASE_PATTERN + r"/posts/statuses"
test = (
("https://www.deviantart.com/t1na/posts/statuses", {
"count": 0,
Expand All @@ -786,9 +786,16 @@ class DeviantartStatusExtractor(DeviantartExtractor):
"count": 1,
"pattern": r"https://images-wixmp-\w+\.wixmp\.com/f"
r"/[^/]+/[^.]+\.jpg\?token=",
}),
# shared sta.sh item
("https://www.deviantart.com/vanillaghosties/posts/statuses", {
"options": (("journals", "none"), ("original", False)),
"range": "5-",
"count": 1,
"keyword": {
"index": int,
"index" : int,
"index_base36": "re:^[0-9a-z]+$",
"url" : "re:^https://sta.sh",
},
}),
("https://www.deviantart.com/justgalym/posts/statuses", {
Expand All @@ -802,7 +809,7 @@ def deviations(self):
yield from self.status(status)

def status(self, status):
for item in status.get("items", ()): # do not trust is_share
for item in status.get("items") or (): # do not trust is_share
# shared deviations/statuses
if "deviation" in item:
yield item["deviation"].copy()
Expand Down

0 comments on commit 597b892

Please sign in to comment.