summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/deviantart.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/deviantart.py')
-rw-r--r--gallery_dl/extractor/deviantart.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py
index 9d1701f..47f589a 100644
--- a/gallery_dl/extractor/deviantart.py
+++ b/gallery_dl/extractor/deviantart.py
@@ -259,9 +259,10 @@ class DeviantartExtractor(Extractor):
@staticmethod
def _find_folder(folders, name):
- pattern = re.compile(r"(?i)\W*" + name.replace("-", r"\W+") + r"\W*$")
+ match = re.compile(name.replace(
+ "-", r"[^a-z0-9]+") + "$", re.IGNORECASE).match
for folder in folders:
- if pattern.match(folder["name"]):
+ if match(folder["name"]):
return folder
raise exception.NotFoundError("folder")
@@ -472,6 +473,12 @@ class DeviantartFolderExtractor(DeviantartExtractor):
"count": ">= 4",
"options": (("original", False),),
}),
+ # name starts with '_', special characters (#1451)
+ (("https://www.deviantart.com/justatest235723"
+ "/gallery/69302698/-test-b-c-d-e-f-"), {
+ "count": 1,
+ "options": (("original", False),),
+ }),
("https://shimoda7.deviantart.com/gallery/722019/Miscellaneous"),
("https://yakuzafc.deviantart.com/gallery/37412168/Crafts"),
)
@@ -1230,7 +1237,7 @@ class DeviantartEclipseAPI():
params = {
"username" : user,
"offset" : offset,
- "limit" : "24",
+ "limit" : 24,
"scraps_folder": "true",
}
return self._pagination(endpoint, params)
@@ -1240,8 +1247,8 @@ class DeviantartEclipseAPI():
params = {
"username": user,
"moduleid": self._module_id_watching(user),
- "offset" : None,
- "limit" : "24",
+ "offset" : offset,
+ "limit" : 24,
}
return self._pagination(endpoint, params)
@@ -1260,14 +1267,23 @@ class DeviantartEclipseAPI():
except Exception:
return {"error": response.text}
- def _pagination(self, endpoint, params=None):
+ def _pagination(self, endpoint, params):
while True:
data = self._call(endpoint, params)
- yield from data["results"]
- if not data["hasMore"]:
+ results = data.get("results")
+ if results is None:
+ return
+ yield from results
+
+ if not data.get("hasMore"):
return
- params["offset"] = data["nextOffset"]
+
+ next_offset = data.get("nextOffset")
+ if next_offset:
+ params["offset"] = next_offset
+ else:
+ params["offset"] += params["limit"]
def _module_id_watching(self, user):
url = "{}/{}/about".format(self.extractor.root, user)