From 87901cc20e3fd89922fd9c60f631455b1c50a797 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 29 Apr 2008 18:08:15 +0200 Subject: [PATCH] add normalizeImdbId --- oxutils/normalize.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oxutils/normalize.py b/oxutils/normalize.py index abad979..8ad69e0 100644 --- a/oxutils/normalize.py +++ b/oxutils/normalize.py @@ -1,7 +1,7 @@ # -*- Mode: Python; -*- # -*- coding: utf-8 -*- # vi:si:et:sw=2:sts=2:ts=2 - +import re _articles = ('the', 'la', 'a', 'die', 'der', 'le', 'el', "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])) 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 +