1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[deviantart] fix sta.sh folder extraction

This commit is contained in:
Mike Fährmann 2024-10-11 09:51:20 +02:00
parent 1f5f04e673
commit 5dd17910d1
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 8 additions and 20 deletions

View File

@ -907,19 +907,18 @@ class DeviantartStashExtractor(DeviantartExtractor):
archive_fmt = "{index}.{extension}" archive_fmt = "{index}.{extension}"
pattern = (r"(?:https?://)?(?:(?:www\.)?deviantart\.com/stash|sta\.sh)" pattern = (r"(?:https?://)?(?:(?:www\.)?deviantart\.com/stash|sta\.sh)"
r"/([a-z0-9]+)") r"/([a-z0-9]+)")
example = "https://sta.sh/abcde" example = "https://www.deviantart.com/stash/abcde"
skip = Extractor.skip skip = Extractor.skip
def __init__(self, match): def __init__(self, match):
DeviantartExtractor.__init__(self, match) DeviantartExtractor.__init__(self, match)
self.user = None self.user = None
self.stash_id = match.group(1)
def deviations(self, stash_id=None): def deviations(self, stash_id=None):
if stash_id is None: if stash_id is None:
stash_id = self.stash_id stash_id = self.groups[0]
url = "https://sta.sh/" + stash_id url = "https://www.deviantart.com/stash/" + stash_id
page = self._limited_request(url).text page = self._limited_request(url).text
if stash_id[0] == "0": if stash_id[0] == "0":
@ -932,19 +931,11 @@ class DeviantartStashExtractor(DeviantartExtractor):
yield deviation yield deviation
return return
for item in text.extract_iter( for sid in text.extract_iter(
page, 'class="stash-thumb-container', '</div>'): page, 'href="https://www.deviantart.com/stash/', '"'):
url = text.extr(item, '<a href="', '"') if sid == stash_id or sid.endswith("#comments"):
continue
if url: yield from self.deviations(sid)
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)
class DeviantartFavoriteExtractor(DeviantartExtractor): class DeviantartFavoriteExtractor(DeviantartExtractor):

View File

@ -61,7 +61,6 @@ __tests__ = (
"transparency": bool, "transparency": bool,
"width" : int, "width" : int,
}, },
"da_category" : str,
"date" : datetime.datetime, "date" : datetime.datetime,
"deviationid" : str, "deviationid" : str,
"?download_filesize": int, "?download_filesize": int,
@ -283,7 +282,6 @@ __tests__ = (
"transparency": False, "transparency": False,
"width" : 6400 "width" : 6400
}, },
"da_category" : "Uncategorized",
"date" : "dt:2024-01-02 21:16:06", "date" : "dt:2024-01-02 21:16:06",
"deviationid" : "8C8D6B28-766A-DE21-7F7D-CE055C3BD50A", "deviationid" : "8C8D6B28-766A-DE21-7F7D-CE055C3BD50A",
"download_filesize": 84510, "download_filesize": 84510,
@ -375,7 +373,6 @@ __tests__ = (
"height" : 128, "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.+", "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", "date" : "dt:2018-12-26 14:49:27",
"deviationid" : "A4A6AD52-8857-46EE-ABFE-86D49D4FF9D0", "deviationid" : "A4A6AD52-8857-46EE-ABFE-86D49D4FF9D0",
"download_filesize": 380, "download_filesize": 380,