mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
* [kemonoparty] add 'favorites' option (#2826) * [kemonoparty] add regex for the url parameter and fallback on the config option * [kemonoparty] simplify
This commit is contained in:
parent
a799fae2df
commit
574e38a287
@ -1550,6 +1550,18 @@ Description
|
||||
Extract a user's direct messages as ``dms`` metadata.
|
||||
|
||||
|
||||
extractor.kemonoparty.favorites
|
||||
---------------------------
|
||||
Type
|
||||
``string``
|
||||
Default
|
||||
``artist``
|
||||
Description
|
||||
Determines the type of favorites to be downloaded.
|
||||
|
||||
Available types are ``artist``, and ``post``.
|
||||
|
||||
|
||||
extractor.kemonoparty.files
|
||||
---------------------------
|
||||
Type
|
||||
|
@ -440,20 +440,44 @@ class KemonopartyDiscordServerExtractor(KemonopartyExtractor):
|
||||
class KemonopartyFavoriteExtractor(KemonopartyExtractor):
|
||||
"""Extractor for kemono.party favorites"""
|
||||
subcategory = "favorite"
|
||||
pattern = BASE_PATTERN + r"/favorites"
|
||||
test = ("https://kemono.party/favorites", {
|
||||
"pattern": KemonopartyUserExtractor.pattern,
|
||||
"url": "f4b5b796979bcba824af84206578c79101c7f0e1",
|
||||
"count": 3,
|
||||
})
|
||||
pattern = BASE_PATTERN + r"/favorites(?:/?\?([^#]+))?"
|
||||
test = (
|
||||
("https://kemono.party/favorites", {
|
||||
"pattern": KemonopartyUserExtractor.pattern,
|
||||
"url": "f4b5b796979bcba824af84206578c79101c7f0e1",
|
||||
"count": 3,
|
||||
}),
|
||||
("https://kemono.party/favorites?type=post", {
|
||||
"pattern": KemonopartyPostExtractor.pattern,
|
||||
"url": "ecfccf5f0d50b8d14caa7bbdcf071de5c1e5b90f",
|
||||
"count": 3,
|
||||
}),
|
||||
)
|
||||
|
||||
def __init__(self, match):
|
||||
KemonopartyExtractor.__init__(self, match)
|
||||
self.favorites = (text.parse_query(match.group(2)).get("type") or
|
||||
self.config("favorites") or
|
||||
"artist")
|
||||
|
||||
def items(self):
|
||||
self._prepare_ddosguard_cookies()
|
||||
self.login()
|
||||
|
||||
users = self.request(self.root + "/api/favorites").json()
|
||||
for user in users:
|
||||
user["_extractor"] = KemonopartyUserExtractor
|
||||
url = "{}/{}/user/{}".format(
|
||||
self.root, user["service"], user["id"])
|
||||
yield Message.Queue, url, user
|
||||
if self.favorites == "artist":
|
||||
users = self.request(
|
||||
self.root + "/api/v1/account/favorites?type=artist").json()
|
||||
for user in users:
|
||||
user["_extractor"] = KemonopartyUserExtractor
|
||||
url = "{}/{}/user/{}".format(
|
||||
self.root, user["service"], user["id"])
|
||||
yield Message.Queue, url, user
|
||||
|
||||
elif self.favorites == "post":
|
||||
posts = self.request(
|
||||
self.root + "/api/v1/account/favorites?type=post").json()
|
||||
for post in posts:
|
||||
post["_extractor"] = KemonopartyPostExtractor
|
||||
url = "{}/{}/user/{}/post/{}".format(
|
||||
self.root, post["service"], post["user"], post["id"])
|
||||
yield Message.Queue, url, post
|
||||
|
Loading…
Reference in New Issue
Block a user