mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
merge #6001: [e621] cache pool metadata API calls
This commit is contained in:
commit
54e1023046
@ -10,6 +10,7 @@
|
||||
|
||||
from .common import Message
|
||||
from . import danbooru
|
||||
from ..cache import memcache
|
||||
from .. import text, util
|
||||
|
||||
|
||||
@ -44,16 +45,11 @@ class E621Extractor(danbooru.DanbooruExtractor):
|
||||
self.root[8:], md5[0:2], md5[2:4], md5, file["ext"])
|
||||
|
||||
if notes and post.get("has_notes"):
|
||||
url = "{}/notes.json?search[post_id]={}".format(
|
||||
self.root, post["id"])
|
||||
post["notes"] = self.request(url).json()
|
||||
post["notes"] = self._get_notes(post["id"])
|
||||
|
||||
if pools and post["pools"]:
|
||||
url = "{}/pools.json?search[id]={}".format(
|
||||
self.root, ",".join(map(str, post["pools"])))
|
||||
post["pools"] = _pools = self.request(url).json()
|
||||
for pool in _pools:
|
||||
pool["name"] = pool["name"].replace("_", " ")
|
||||
post["pools"] = self._get_pools(
|
||||
",".join(map(str, post["pools"])))
|
||||
|
||||
post["filename"] = file["md5"]
|
||||
post["extension"] = file["ext"]
|
||||
@ -64,6 +60,18 @@ class E621Extractor(danbooru.DanbooruExtractor):
|
||||
yield Message.Directory, post
|
||||
yield Message.Url, file["url"], post
|
||||
|
||||
def _get_notes(self, id):
|
||||
return self.request(
|
||||
"{}/notes.json?search[post_id]={}".format(self.root, id)).json()
|
||||
|
||||
@memcache(keyarg=1)
|
||||
def _get_pools(self, ids):
|
||||
pools = self.request(
|
||||
"{}/pools.json?search[id]={}".format(self.root, ids)).json()
|
||||
for pool in pools:
|
||||
pool["name"] = pool["name"].replace("_", " ")
|
||||
return pools
|
||||
|
||||
|
||||
BASE_PATTERN = E621Extractor.update({
|
||||
"e621": {
|
||||
|
Loading…
Reference in New Issue
Block a user