add normalizeImdbId

This commit is contained in:
j 2008-04-29 18:08:15 +02:00
parent 97689014f2
commit 87901cc20e

View file

@ -1,7 +1,7 @@
# -*- Mode: Python; -*- # -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=2:sts=2:ts=2
import re
_articles = ('the', 'la', 'a', 'die', 'der', 'le', 'el', _articles = ('the', 'la', 'a', 'die', 'der', 'le', 'el',
"l'", 'il', 'das', 'les', 'o', 'ein', 'i', 'un', 'los', 'de', "l'", 'il', 'das', 'les', 'o', 'ein', 'i', 'un', 'los', 'de',
@ -51,3 +51,10 @@ def normalizeTitle(title):
title = '%s%s%s' % (stitle[-1], sep, ', '.join(stitle[:-1])) title = '%s%s%s' % (stitle[-1], sep, ', '.join(stitle[:-1]))
return title return title
def normalizeImdbId(imdbId):
if isinstance(imdbId, basestring):
imdbId = re.sub('.*(\d{7}).*', '\\1', imdbId)
elif isinstance(imdbId, int):
imdbId = "%07d" % imdbId
return imdbId