mirror of
https://github.com/mikf/gallery-dl.git
synced 2025-02-01 03:51:42 +01:00
[kemonoparty] add 'revision_index' metadata field (#4727)
This commit is contained in:
parent
3bbaa875f1
commit
d0effcae20
@ -219,7 +219,14 @@ class KemonopartyExtractor(Extractor):
|
||||
|
||||
@memcache(keyarg=1)
|
||||
def _post_revisions(self, url):
|
||||
return self.request(url + "/revisions").json()
|
||||
revs = self.request(url + "/revisions").json()
|
||||
|
||||
idx = len(revs)
|
||||
for rev in revs:
|
||||
rev["revision_index"] = idx
|
||||
idx -= 1
|
||||
|
||||
return revs
|
||||
|
||||
|
||||
def _validate(response):
|
||||
@ -253,13 +260,15 @@ class KemonopartyUserExtractor(KemonopartyExtractor):
|
||||
if revisions:
|
||||
for post in posts:
|
||||
post["revision_id"] = 0
|
||||
yield post
|
||||
post_url = "{}/post/{}".format(self.api_url, post["id"])
|
||||
try:
|
||||
revs = self._post_revisions(post_url)
|
||||
except exception.HttpError:
|
||||
pass
|
||||
post["revision_index"] = 1
|
||||
yield post
|
||||
else:
|
||||
post["revision_index"] = len(revs) + 1
|
||||
yield post
|
||||
yield from revs
|
||||
else:
|
||||
yield from posts
|
||||
@ -292,8 +301,9 @@ class KemonopartyPostExtractor(KemonopartyExtractor):
|
||||
try:
|
||||
revs = self._post_revisions(self.api_url)
|
||||
except exception.HttpError:
|
||||
pass
|
||||
post["revision_index"] = 1
|
||||
else:
|
||||
post["revision_index"] = len(revs) + 1
|
||||
return itertools.chain((post,), revs)
|
||||
return (post,)
|
||||
|
||||
|
@ -169,13 +169,14 @@ __tests__ = (
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://kemono.party/patreon/user/3161935/post/68231671/revision/134996",
|
||||
"#url" : "https://kemono.su/patreon/user/3161935/post/68231671/revision/142470",
|
||||
"#comment" : "revisions (#4498)",
|
||||
"#category": ("", "kemonoparty", "patreon"),
|
||||
"#class" : kemonoparty.KemonopartyPostExtractor,
|
||||
"#urls" : "https://kemono.party/data/88/52/88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86.jpg",
|
||||
"#urls" : "https://kemono.su/data/88/52/88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86.jpg",
|
||||
|
||||
"revision_id": 134996,
|
||||
"revision_id": 142470,
|
||||
"revision_index": 2,
|
||||
},
|
||||
|
||||
{
|
||||
@ -188,6 +189,7 @@ __tests__ = (
|
||||
"#archive" : False,
|
||||
|
||||
"revision_id": range(134996, 3052965),
|
||||
"revision_index": range(1, 9),
|
||||
},
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user