Skip to content

Commit

Permalink
[deviantart] support '?catpath=/' URLs (#26)
Browse files Browse the repository at this point in the history
They previously weren't supported for galleries and journals.

This also increases the 'limit' parameter for API calls to its
respective maximum.
  • Loading branch information
mikf committed Jul 6, 2017
1 parent 9edbd6f commit 4877ef6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
3 changes: 1 addition & 2 deletions gallery_dl/extractor/4plebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
class FourplebsThreadExtractor(chan.FoolfuukaThreadExtractor):
"""Extractor for images from threads on 4plebs.org"""
category = "4plebs"
root = "https://archive.4plebs.org"
pattern = [r"(?:https?://)?(?:archive\.)?4plebs\.org/([^/]+)/thread/(\d+)"]
test = [("https://archive.4plebs.org/tg/thread/54059290", {
"url": "fd823f17b5001442b941fddcd9ec91bafedfbc79",
"keyword": "97f66d93f6c87b9dc33314a5f9dc7add6ce067e7",
})]
root = "https://archive.4plebs.org"
38 changes: 23 additions & 15 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ def _find(folders, name):
class DeviantartGalleryExtractor(DeviantartExtractor):
"""Extractor for all deviations from an artist's gallery"""
subcategory = "gallery"
pattern = [r"(?:https?://)?([^.]+)\.deviantart\.com(?:/gallery)?/?$"]
test = [("http://shimoda7.deviantart.com/gallery/", {
"url": "63bfa8efba199e27181943c9060f6770f91a8441",
"keyword": "e017b1eec5d052dedbb219259ae8c01d0db678a3",
})]
pattern = [r"(?:https?://)?([^.]+)\.deviantart\.com"
r"(?:/(?:gallery/?(?:\?catpath=/)?)?)?$"]
test = [
("http://shimoda7.deviantart.com/gallery/", {
"url": "63bfa8efba199e27181943c9060f6770f91a8441",
"keyword": "e017b1eec5d052dedbb219259ae8c01d0db678a3",
}),
("http://shimoda7.deviantart.com/gallery/?catpath=/", None),
]

def __init__(self, match):
DeviantartExtractor.__init__(self)
Expand Down Expand Up @@ -279,11 +283,15 @@ def prepare(self, deviation):
class DeviantartJournalExtractor(DeviantartExtractor):
"""Extractor for an artist's journals"""
subcategory = "journal"
pattern = [r"(?:https?://)?([^.]+)\.deviantart\.com/(?:journal|blog)/?$"]
test = [("http://shimoda7.deviantart.com/journal/", {
"url": "f7960ae06e774d6931c61ad309c95a10710658b2",
"keyword": "9ddc2e130198395c1dfaa55c65b6bf63713ec0a8",
})]
pattern = [r"(?:https?://)?([^.]+)\.deviantart\.com"
r"/(?:journal|blog)/?(?:\?catpath=/)?$"]
test = [
("http://shimoda7.deviantart.com/journal/", {
"url": "f7960ae06e774d6931c61ad309c95a10710658b2",
"keyword": "9ddc2e130198395c1dfaa55c65b6bf63713ec0a8",
}),
("http://shimoda7.deviantart.com/journal/?catpath=/", None),
]

def __init__(self, match):
DeviantartExtractor.__init__(self)
Expand All @@ -310,14 +318,14 @@ def __init__(self, extractor, client_id="5388",
def browse_user_journals(self, username, offset=0):
"""Yield all journal entries of a specific user"""
endpoint = "browse/user/journals"
params = {"username": username, "offset": offset, "limit": 10,
params = {"username": username, "offset": offset, "limit": 50,
"mature_content": self.mature, "featured": "false"}
return self._pagination(endpoint, params)

def collections(self, username, folder_id, offset=0):
"""Yield all Deviation-objects contained in a collection folder"""
endpoint = "collections/" + folder_id
params = {"username": username, "offset": offset, "limit": 10,
params = {"username": username, "offset": offset, "limit": 24,
"mature_content": self.mature}
return self._pagination(endpoint, params)

Expand All @@ -342,21 +350,21 @@ def deviation_content(self, deviation_id):
def gallery(self, username, folder_id="", offset=0):
"""Yield all Deviation-objects contained in a gallery folder"""
endpoint = "gallery/" + folder_id
params = {"username": username, "offset": offset, "limit": 10,
params = {"username": username, "offset": offset, "limit": 24,
"mature_content": self.mature, "mode": "newest"}
return self._pagination(endpoint, params)

def gallery_all(self, username, offset=0):
"""Yield all Deviation-objects of a specific user"""
endpoint = "gallery/all"
params = {"username": username, "offset": offset, "limit": 10,
params = {"username": username, "offset": offset, "limit": 24,
"mature_content": self.mature}
return self._pagination(endpoint, params)

def gallery_folders(self, username, offset=0):
"""Yield all gallery folders of a specific user"""
endpoint = "gallery/folders"
params = {"username": username, "offset": offset, "limit": 10,
params = {"username": username, "offset": offset, "limit": 50,
"mature_content": self.mature}
return self._pagination(endpoint, params)

Expand Down

0 comments on commit 4877ef6

Please sign in to comment.