mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[wallhaven] add 'collections' extractor (#1351)
This commit is contained in:
parent
faf561b6ca
commit
e165e6c265
@ -93,6 +93,27 @@ class WallhavenCollectionExtractor(WallhavenExtractor):
|
||||
return {"username": self.username, "collection_id": self.collection_id}
|
||||
|
||||
|
||||
class WallhavenCollectionsExtractor(WallhavenExtractor):
|
||||
"""Extractor for all collections of a wallhaven user"""
|
||||
subcategory = "collections"
|
||||
pattern = r"(?:https?://)?wallhaven\.cc/user/([^/?#]+)/favorites/?$"
|
||||
test = ("https://wallhaven.cc/user/AksumkA/favorites", {
|
||||
"pattern": WallhavenCollectionExtractor.pattern,
|
||||
"count": 4,
|
||||
})
|
||||
|
||||
def __init__(self, match):
|
||||
WallhavenExtractor.__init__(self, match)
|
||||
self.username = match.group(1)
|
||||
|
||||
def items(self):
|
||||
for collection in WallhavenAPI(self).collections(self.username):
|
||||
collection["_extractor"] = WallhavenCollectionExtractor
|
||||
url = "https://wallhaven.cc/user/{}/favorites/{}".format(
|
||||
self.username, collection["id"])
|
||||
yield Message.Queue, url, collection
|
||||
|
||||
|
||||
class WallhavenImageExtractor(WallhavenExtractor):
|
||||
"""Extractor for individual wallpaper on wallhaven.cc"""
|
||||
subcategory = "image"
|
||||
@ -187,7 +208,7 @@ class WallhavenAPI():
|
||||
data = self._call(endpoint, params)
|
||||
yield from data["data"]
|
||||
|
||||
meta = data["meta"]
|
||||
if meta["current_page"] >= meta["last_page"]:
|
||||
meta = data.get("meta")
|
||||
if not meta or meta["current_page"] >= meta["last_page"]:
|
||||
return
|
||||
params["page"] = meta["current_page"] + 1
|
||||
|
@ -152,13 +152,16 @@ SUBCATEGORY_MAP = {
|
||||
"media": "Media Timelines",
|
||||
"list-members": "List Members",
|
||||
},
|
||||
"wikiart": {
|
||||
"artists": "Artist Listings",
|
||||
"wallhaven": {
|
||||
"collections": "",
|
||||
},
|
||||
"weasyl": {
|
||||
"journals" : "",
|
||||
"submissions": "",
|
||||
},
|
||||
"wikiart": {
|
||||
"artists": "Artist Listings",
|
||||
},
|
||||
}
|
||||
|
||||
_OAUTH = "`OAuth <https://github.com/mikf/gallery-dl#oauth>`__"
|
||||
|
Loading…
Reference in New Issue
Block a user