[imdb] explicit unicode conversion

This commit is contained in:
Julien Veyssier 2013-03-06 14:55:20 +01:00
commit cd8d2bfada
2 changed files with 6 additions and 6 deletions

View file

@ -77,7 +77,7 @@ class ImdbBrowser(BaseBrowser):
other_titles = [] other_titles = []
roles = {} roles = {}
title = u'%s'%jres['title'].strip() title = unicode(jres['title'].strip())
if jres.has_key('runtime'): if jres.has_key('runtime'):
dur_str = jres['runtime'][0].split(':') dur_str = jres['runtime'][0].split(':')
if len(dur_str) == 1: if len(dur_str) == 1:
@ -106,7 +106,7 @@ class ImdbBrowser(BaseBrowser):
country += '%s, '%c country += '%s, '%c
country = country[:-2] country = country[:-2]
if jres.has_key('plot_simple'): if jres.has_key('plot_simple'):
description = u'%s'%jres['plot_simple'] description = unicode(jres['plot_simple'])
if jres.has_key('rating') and jres.has_key('rating_count'): if jres.has_key('rating') and jres.has_key('rating_count'):
note = u'%s/10 (%s votes)'%(jres['rating'],jres['rating_count']) note = u'%s/10 (%s votes)'%(jres['rating'],jres['rating_count'])
for r in ['actor','director','writer']: for r in ['actor','director','writer']:

View file

@ -110,19 +110,19 @@ class PersonPage(BasePage):
td_overview = self.parser.select(self.document.getroot(),'td#overview-top',1) td_overview = self.parser.select(self.document.getroot(),'td#overview-top',1)
descs = self.parser.select(td_overview,'span[itemprop=description]') descs = self.parser.select(td_overview,'span[itemprop=description]')
if len(descs) > 0: if len(descs) > 0:
short_biography = u'%s'%descs[0].text short_biography = unicode(descs[0].text)
rname_block = self.parser.select(td_overview,'div.txt-block h4.inline') rname_block = self.parser.select(td_overview,'div.txt-block h4.inline')
if len(rname_block) > 0 and "born" in rname_block[0].text.lower(): if len(rname_block) > 0 and "born" in rname_block[0].text.lower():
links = self.parser.select(rname_block[0].getparent(),'a') links = self.parser.select(rname_block[0].getparent(),'a')
for a in links: for a in links:
href = a.attrib.get('href','').strip() href = a.attrib.get('href','').strip()
if href == 'bio': if href == 'bio':
real_name = u'%s'%a.text.strip() real_name = unicode(a.text.strip())
elif 'birth_place' in href: elif 'birth_place' in href:
birth_place = u'%s'%a.text.lower().strip() birth_place = unicode(a.text.lower().strip())
names = self.parser.select(td_overview,'h1[itemprop=name]') names = self.parser.select(td_overview,'h1[itemprop=name]')
if len(names) > 0: if len(names) > 0:
name = u'%s'%names[0].text.strip() name = unicode(names[0].text.strip())
times = self.parser.select(td_overview,'time[itemprop=birthDate]') times = self.parser.select(td_overview,'time[itemprop=birthDate]')
if len(times) > 0: if len(times) > 0:
time = times[0].attrib.get('datetime','').split('-') time = times[0].attrib.get('datetime','').split('-')