add timeout to imdb.guess

This commit is contained in:
j 2010-01-24 10:25:41 +05:30
parent 51a0c7dc4a
commit 9899cf89a1

View file

@ -673,7 +673,7 @@ class IMDb:
return self.credits return self.credits
def guess(title, director=''): def guess(title, director='', timeout=google.DEFAULT_TIMEOUT):
#FIXME: proper file -> title #FIXME: proper file -> title
title = title.split('-')[0] title = title.split('-')[0]
title = title.split('(')[0] title = title.split('(')[0]
@ -688,7 +688,7 @@ def guess(title, director=''):
search = 'site:imdb.com %s "%s"' % (director, title) search = 'site:imdb.com %s "%s"' % (director, title)
else: else:
search = 'site:imdb.com "%s"' % title search = 'site:imdb.com "%s"' % title
for (name, url, desc) in google.find(search, 2): for (name, url, desc) in google.find(search, 2, timeout=timeout):
if url.startswith('http://www.imdb.com/title/tt'): if url.startswith('http://www.imdb.com/title/tt'):
return normalizeImdbId(int(oxlib.intValue(url))) return normalizeImdbId(int(oxlib.intValue(url)))