fix imdb serach and mapping

This commit is contained in:
j 2009-07-10 10:47:01 +02:00
parent bb8db87d02
commit 03af5a3de0
2 changed files with 27 additions and 16 deletions

View file

@ -185,6 +185,21 @@ def getMovieInfo(imdbId):
return info
def getMovieRuntimeSeconds(imdbId):
info = getMovieInfo(imdbId)
value = info['runtime'][0]
parsed_value = findRe(value, '(.*?) min')
parsed_value = findRe(parsed_value, '([0-9]+)')
if not parsed_value:
parsed_value = findRe(value, '(.*?) sec')
parsed_value = findRe(parsed_value, '([0-9]+)')
if not parsed_value:
parsed_value = 0
else:
parsed_value = int(parsed_value)
else:
parsed_value = int(parsed_value) * 60
return parsed_value
def getMoviePoster(imdbId):
info = getMovieInfo(imdbId)
@ -505,17 +520,7 @@ class IMDb:
if key in ('runtime', 'language', 'genre', 'country', 'tagline', 'plot_outline'):
value = stripTags(value).strip()
if key == 'runtime':
parsed_value = findRe(value, '(.*?) min')
parsed_value = findRe(parsed_value, '([0-9]+)')
if not parsed_value:
parsed_value = findRe(value, '(.*?) sec')
parsed_value = findRe(parsed_value, '([0-9]+)')
if not parsed_value:
parsed_value = 0
else:
parsed_value = int(parsed_value)
else:
parsed_value = int(parsed_value) * 60
parsed_value = getMovieRuntimeSeconds(self.imdb)
elif key in ('country', 'language'):
parsed_value = value.split(' / ')
if len(parsed_value) == 1:

View file

@ -15,7 +15,7 @@ def getMovieId(title, director='', year=''):
return ''
def getUrlByImdbId(imdbId):
query = '"imdb_id = %s"'% imdbId
query = '"%s"'% imdbId
result = find(query)
if result:
url = result[0][1]
@ -45,16 +45,22 @@ def getWikiData(wikipediaUrl):
def getMovieData(wikipediaUrl):
data = getWikiData(wikipediaUrl)
filmbox_data = findRe(data, '''\{\{Infobox.Film(.*?)\}\}''')
filmbox_data = findRe(data, '''\{\{Infobox.Film(.*?)\n\}\}''')
filmbox = {}
for row in filmbox_data.strip().split('|'):
for row in filmbox_data.strip().split('\n|'):
d = row.split('=')
if len(d) == 2:
key = d[0].strip()
if key[0] == '|':
key = key[1:]
value = d[1].strip()
filmbox[key] = value
if 'amg_id' in filmbox:
filmbox['amg_id'] = filmbox['amg_id'].split('1:')[-1]
if 'imdb title' in data:
filmbox['imdb_id'] = findRe(data, 'imdb title\|(\d*?)\|')
if 'Amg movie' in data:
filmbox['amg_id'] = findRe(data, 'Amg movie\|(\d*?)\|')
if 'rotten-tomatoes' in data:
filmbox['rottentomatoes_id'] = findRe(data, 'rotten-tomatoes\|id\=(.*?)\|')
return filmbox
def getImageUrl(name):