votes and ratings

This commit is contained in:
j 2007-03-02 16:47:28 +00:00
parent ca2a42e773
commit a9c8d43f6b
1 changed files with 7 additions and 3 deletions

View File

@ -163,13 +163,17 @@ class IMDb:
if IMDbDict['title'][0] == '"' and IMDbDict['title'][-1] == '"':
IMDbDict['title'] = IMDbDict['title'][1:-1]
#Votes
m = re.compile('<b>(.*?)/10</b> \(<a href="ratings">(.*?) votes</a>\)', re.IGNORECASE).search(data)
#Rating
m = re.compile('<b>(.*?)/10</b>', 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('<small>\(<a href="ratings">(.*?) votes</a>\)</small>', re.IGNORECASE).search(data)
if m:
IMDbDict['votes'] = int(m.group(1).replace(',', ''))
else:
IMDbDict['votes'] = -1
data = data.replace('\n',' ')