From a9c8d43f6be029cf40595754e8e1b460fc187209 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 2 Mar 2007 16:47:28 +0000 Subject: [PATCH] votes and ratings --- scrapeit/imdb.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scrapeit/imdb.py b/scrapeit/imdb.py index 0b507cc..ad016e0 100644 --- a/scrapeit/imdb.py +++ b/scrapeit/imdb.py @@ -163,13 +163,17 @@ class IMDb: if IMDbDict['title'][0] == '"' and IMDbDict['title'][-1] == '"': IMDbDict['title'] = IMDbDict['title'][1:-1] - #Votes - m = re.compile('(.*?)/10 \((.*?) votes\)', re.IGNORECASE).search(data) + #Rating + m = re.compile('(.*?)/10', re.IGNORECASE).search(data) if m: IMDbDict['rating'] = int(float(m.group(1)) * 1000) - IMDbDict['votes'] = int(m.group(2).replace(',', '')) else: IMDbDict['rating'] = -1 + #Votes + m = re.compile('\((.*?) votes\)', re.IGNORECASE).search(data) + if m: + IMDbDict['votes'] = int(m.group(1).replace(',', '')) + else: IMDbDict['votes'] = -1 data = data.replace('\n',' ')