mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[kemonoparty] add 'metadata' option (closes #1548)
to fetch creator names with an additional HTTP request
This commit is contained in:
parent
559462789d
commit
0717456b4e
@ -1176,6 +1176,16 @@ Description
|
||||
Download video files.
|
||||
|
||||
|
||||
extractor.kemonoparty.metadata
|
||||
------------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``false``
|
||||
Description
|
||||
Extract ``username`` metadata
|
||||
|
||||
|
||||
extractor.khinsider.format
|
||||
--------------------------
|
||||
Type
|
||||
|
@ -26,6 +26,12 @@ class KemonopartyExtractor(Extractor):
|
||||
def items(self):
|
||||
find_inline = re.compile(r'src="(/inline/[^"]+)').findall
|
||||
|
||||
if self.config("metadata"):
|
||||
username = text.unescape(text.extract(
|
||||
self.request(self.user_url).text, "<title>", " | Kemono<")[0])
|
||||
else:
|
||||
username = None
|
||||
|
||||
for post in self.posts():
|
||||
|
||||
files = []
|
||||
@ -38,6 +44,8 @@ class KemonopartyExtractor(Extractor):
|
||||
|
||||
post["date"] = text.parse_datetime(
|
||||
post["published"], "%a, %d %b %Y %H:%M:%S %Z")
|
||||
if username:
|
||||
post["username"] = username
|
||||
yield Message.Directory, post
|
||||
|
||||
for post["num"], file in enumerate(files, 1):
|
||||
@ -67,6 +75,7 @@ class KemonopartyUserExtractor(KemonopartyExtractor):
|
||||
KemonopartyExtractor.__init__(self, match)
|
||||
service, user_id = match.groups()
|
||||
self.api_url = "{}/api/{}/user/{}".format(self.root, service, user_id)
|
||||
self.user_url = "{}/{}/user/{}".format(self.root, service, user_id)
|
||||
|
||||
def posts(self):
|
||||
url = self.api_url
|
||||
@ -125,6 +134,7 @@ class KemonopartyPostExtractor(KemonopartyExtractor):
|
||||
service, user_id, post_id = match.groups()
|
||||
self.api_url = "{}/api/{}/user/{}/post/{}".format(
|
||||
self.root, service, user_id, post_id)
|
||||
self.user_url = "{}/{}/user/{}".format(self.root, service, user_id)
|
||||
|
||||
def posts(self):
|
||||
posts = self.request(self.api_url).json()
|
||||
|
Loading…
Reference in New Issue
Block a user