Skip to content

Commit

Permalink
[deviantart] fix sta.sh folder extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Oct 11, 2024
1 parent 1f5f04e commit 5dd1791
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
25 changes: 8 additions & 17 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,19 +907,18 @@ class DeviantartStashExtractor(DeviantartExtractor):
archive_fmt = "{index}.{extension}"
pattern = (r"(?:https?://)?(?:(?:www\.)?deviantart\.com/stash|sta\.sh)"
r"/([a-z0-9]+)")
example = "https://sta.sh/abcde"
example = "https://www.deviantart.com/stash/abcde"

skip = Extractor.skip

def __init__(self, match):
DeviantartExtractor.__init__(self, match)
self.user = None
self.stash_id = match.group(1)

def deviations(self, stash_id=None):
if stash_id is None:
stash_id = self.stash_id
url = "https://sta.sh/" + stash_id
stash_id = self.groups[0]
url = "https://www.deviantart.com/stash/" + stash_id
page = self._limited_request(url).text

if stash_id[0] == "0":
Expand All @@ -932,19 +931,11 @@ def deviations(self, stash_id=None):
yield deviation
return

for item in text.extract_iter(
page, 'class="stash-thumb-container', '</div>'):
url = text.extr(item, '<a href="', '"')

if url:
stash_id = url.rpartition("/")[2]
else:
stash_id = text.extr(item, 'gmi-stashid="', '"')
stash_id = "2" + util.bencode(text.parse_int(
stash_id), "0123456789abcdefghijklmnopqrstuvwxyz")

if len(stash_id) > 2:
yield from self.deviations(stash_id)
for sid in text.extract_iter(
page, 'href="https://www.deviantart.com/stash/', '"'):
if sid == stash_id or sid.endswith("#comments"):
continue
yield from self.deviations(sid)


class DeviantartFavoriteExtractor(DeviantartExtractor):
Expand Down
3 changes: 0 additions & 3 deletions test/results/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"transparency": bool,
"width" : int,
},
"da_category" : str,
"date" : datetime.datetime,
"deviationid" : str,
"?download_filesize": int,
Expand Down Expand Up @@ -283,7 +282,6 @@
"transparency": False,
"width" : 6400
},
"da_category" : "Uncategorized",
"date" : "dt:2024-01-02 21:16:06",
"deviationid" : "8C8D6B28-766A-DE21-7F7D-CE055C3BD50A",
"download_filesize": 84510,
Expand Down Expand Up @@ -375,7 +373,6 @@
"height" : 128,
"src" : r"re:https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/940f2d05-c5eb-4917-8192-7eb6a2d508c6/dcvdmbc-e506cdcf-3208-4c20-85ab-0bfa8a7bcb16.png\?token=ey.+",
},
"da_category" : "Uncategorized",
"date" : "dt:2018-12-26 14:49:27",
"deviationid" : "A4A6AD52-8857-46EE-ABFE-86D49D4FF9D0",
"download_filesize": 380,
Expand Down

0 comments on commit 5dd1791

Please sign in to comment.