There can be more than 50 people.
This commit is contained in:
parent
077cdcfeb2
commit
bb68a46f59
|
@ -1,5 +1,5 @@
|
|||
from .model import HumanItem
|
||||
from . import mediawiki
|
||||
from . import mediawiki, utils
|
||||
import re
|
||||
|
||||
re_four_digits = re.compile(r'\b\d{4}\b')
|
||||
|
@ -41,7 +41,8 @@ def from_name(name):
|
|||
qids = list(lookup.keys())
|
||||
|
||||
found = []
|
||||
for entity in mediawiki.get_entities_with_cache(qids, props='labels|descriptions'):
|
||||
for cur in utils.chunk(qids, 50):
|
||||
for entity in mediawiki.get_entities_with_cache(cur, props='labels|descriptions'):
|
||||
qid = entity['id']
|
||||
item = lookup[qid]
|
||||
i = {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import requests
|
||||
import os
|
||||
import json
|
||||
import hashlib
|
||||
from .category import Category
|
||||
|
||||
wikidata_url = 'https://www.wikidata.org/w/api.php'
|
||||
|
@ -64,7 +65,9 @@ def get_entity_with_cache(qid, refresh=False):
|
|||
return entity
|
||||
|
||||
def get_entities_with_cache(ids, **params):
|
||||
filename = f'cache/entities_{"_".join(ids)}.json'
|
||||
md5 = hashlib.md5(' '.join(ids).encode('utf-8')).hexdigest()
|
||||
|
||||
filename = f'cache/entities_{md5}.json'
|
||||
if os.path.exists(filename):
|
||||
entity = json.load(open(filename))
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue