cleanup imdb titles, fixes #957

This commit is contained in:
j 2012-09-14 11:17:34 +02:00
parent 9f4020e238
commit 36c6e6908e

View file

@ -302,16 +302,19 @@ class Imdb(SiteParser):
self['title'] = self.get('englishTitle', self['originalTitle']) self['title'] = self.get('englishTitle', self['originalTitle'])
for t in ('title', 'englishTitle', 'originalTitle'): for t in ('title', 'englishTitle', 'originalTitle'):
if t in self and self[t].startswith('"') and self[t].endswith('"'): if t in self:
self[t] = self[t][1:-1] if self[t].startswith('"') and self[t].endswith('"'):
self[t] = self[t][1:-1]
self[t] = re.sub('\(\#[.\d]+\)', '', self[t])
if 'alternativeTitles' in self: if 'alternativeTitles' in self:
if len(self['alternativeTitles']) == 2 and \ if len(self['alternativeTitles']) == 2 and \
isinstance(self['alternativeTitles'][0], basestring): isinstance(self['alternativeTitles'][0], basestring):
self['alternativeTitles'] = [self['alternativeTitles']] self['alternativeTitles'] = [self['alternativeTitles']]
self['alternativeTitles'] = [[t[0], self['alternativeTitles'] = [[re.sub('\(\#[.\d]+\)', '', t[0]),
t[1].split(' / ')[0].split('(')[0].strip()] t[1].split(' / ')[0].split('(')[0].strip()]
for t in self['alternativeTitles']] for t in self['alternativeTitles']]
#self[t] = re.sub('\(\#[.\d]+\)', '', self[t])
if 'runtime' in self and self['runtime']: if 'runtime' in self and self['runtime']:
if 'min' in self['runtime']: base=60 if 'min' in self['runtime']: base=60