new imdb title code

This commit is contained in:
j 2007-05-22 18:01:28 +00:00
commit 3942d76b6e
2 changed files with 18 additions and 5 deletions

View file

@ -157,11 +157,16 @@ class IMDb:
#Title, Year
title = u''
year = u''
flat_data = data.replace('\n', '').replace('\r', '')
html_title = re.compile('<strong class="title">(.*?) <small>\(<a href="/Sections/Years/(.*?)">').findall(flat_data)
soup = BeautifulSoup(data)
html_title = soup('div', {'id': 'tn15title'})
if html_title: html_title = html_title[0]('h1')
if html_title: html_title = html_title[0].contents
if html_title:
title = html_title[0][0]
IMDbDict['year'] = html_title[0][1]
title = html_title[0]
year = re.compile('(\d\d\d\d)').findall(str(html_title[1]))
if year: year = year[0]
else: year = ''
IMDbDict['year'] = year
IMDbDict['title'] = stripTags(title).strip()
else:
title = _getTerm(data, '<title>(.*?)</title>')