From d3069d43c6eaccae678083ded203479e523325c1 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 7 Jan 2010 01:08:08 +0100 Subject: [PATCH] use only one year parser, more relaxed about user rating --- oxweb/imdb.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/oxweb/imdb.py b/oxweb/imdb.py index 3543714..c70b418 100644 --- a/oxweb/imdb.py +++ b/oxweb/imdb.py @@ -184,6 +184,8 @@ def getMovieInfo(imdbId, timeout=-1): #Votes info['votes'] = -1 if "user rating" in info: + if isinstance(info['user rating'], list): + info['user rating'] = ' '.join(info['user rating']) votes = findRe(info['user rating'], '([\d,]*?) votes') if votes: info['votes'] = int(votes.replace(',', '')) @@ -578,22 +580,7 @@ class IMDb: return parsed_value def parseYear(self): - year = '' - data = self.getPage() - soup = BeautifulSoup(data) - html_title = soup('div', {'id': 'tn15title'}) - if not html_title: - html_title = soup('title') - if html_title: - html_title = unicode(html_title[0]) - html_title = stripTags(html_title) - year = re.compile('\((\d{4})\)').findall(html_title) - if not year: - year = re.compile('\((\d{4})/').findall(html_title) - if year: - year = year[0] - else: year = '' - return year + return getMovieYear(self.imdb) def parse(self): data = self.getPage()