This commit is contained in:
j 2019-08-08 17:08:13 +02:00
parent 388f33ebb6
commit 665a4038b2

View file

@ -17,7 +17,7 @@ def get_id(url):
def get_url(id=None, imdb=None, allmovie=None):
if imdb:
query = '"%s"'% imdb
query = '"%s"' % imdb
result = find(query)
if result:
url = result[0][1]
@ -26,7 +26,7 @@ def get_url(id=None, imdb=None, allmovie=None):
return url
return ""
if allmovie:
query = '"amg_id = 1:%s"'% allmovie
query = '"amg_id = 1:%s"' % allmovie
result = find(query)
if result:
url = result[0][1]
@ -140,7 +140,7 @@ def get_allmovie_id(wikipedia_url):
return data.get('amg_id', '')
def find(query, max_results=10):
query = {'action': 'query', 'list':'search', 'format': 'json',
query = {'action': 'query', 'list': 'search', 'format': 'json',
'srlimit': max_results, 'srwhat': 'text', 'srsearch': query.encode('utf-8')}
url = "http://en.wikipedia.org/w/api.php?" + urllib.parse.urlencode(query)
data = read_url(url)