* [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:
@@ -1550,6 +1550,18 @@ Description
|
|||||||
Extract a user's direct messages as ``dms`` metadata.
|
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
|
extractor.kemonoparty.files
|
||||||
---------------------------
|
---------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -440,20 +440,44 @@ class KemonopartyDiscordServerExtractor(KemonopartyExtractor):
|
|||||||
class KemonopartyFavoriteExtractor(KemonopartyExtractor):
|
class KemonopartyFavoriteExtractor(KemonopartyExtractor):
|
||||||
"""Extractor for kemono.party favorites"""
|
"""Extractor for kemono.party favorites"""
|
||||||
subcategory = "favorite"
|
subcategory = "favorite"
|
||||||
pattern = BASE_PATTERN + r"/favorites"
|
pattern = BASE_PATTERN + r"/favorites(?:/?\?([^#]+))?"
|
||||||
test = ("https://kemono.party/favorites", {
|
test = (
|
||||||
"pattern": KemonopartyUserExtractor.pattern,
|
("https://kemono.party/favorites", {
|
||||||
"url": "f4b5b796979bcba824af84206578c79101c7f0e1",
|
"pattern": KemonopartyUserExtractor.pattern,
|
||||||
"count": 3,
|
"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):
|
def items(self):
|
||||||
self._prepare_ddosguard_cookies()
|
self._prepare_ddosguard_cookies()
|
||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
users = self.request(self.root + "/api/favorites").json()
|
if self.favorites == "artist":
|
||||||
for user in users:
|
users = self.request(
|
||||||
user["_extractor"] = KemonopartyUserExtractor
|
self.root + "/api/v1/account/favorites?type=artist").json()
|
||||||
url = "{}/{}/user/{}".format(
|
for user in users:
|
||||||
self.root, user["service"], user["id"])
|
user["_extractor"] = KemonopartyUserExtractor
|
||||||
yield Message.Queue, url, user
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user