cleanup title in one place

This commit is contained in:
j 2012-09-14 11:27:36 +02:00
parent 36c6e6908e
commit 7a8609f5cf

View file

@ -301,17 +301,20 @@ class Imdb(SiteParser):
self['englishTitle'] = ititle[0][0] self['englishTitle'] = ititle[0][0]
self['title'] = self.get('englishTitle', self['originalTitle']) self['title'] = self.get('englishTitle', self['originalTitle'])
def cleanup_title(title):
if title.startswith('"') and title.endswith('"'):
title = title[1:-1]
title = re.sub('\(\#[.\d]+\)', '', title)
return title
for t in ('title', 'englishTitle', 'originalTitle'): for t in ('title', 'englishTitle', 'originalTitle'):
if t in self: if t in self:
if self[t].startswith('"') and self[t].endswith('"'): self[t] = cleanup_title(self[t])
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'] = [[re.sub('\(\#[.\d]+\)', '', t[0]), self['alternativeTitles'] = [[cleanup_title(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]) #self[t] = re.sub('\(\#[.\d]+\)', '', self[t])