From 8431f02527c97061d8e72f34e1d0393d177b1814 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 17 Sep 2010 16:11:37 +0200 Subject: [PATCH] adding new 0xDB Id function --- pandora/backend/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora/backend/utils.py b/pandora/backend/utils.py index a289dee..d7122c5 100644 --- a/pandora/backend/utils.py +++ b/pandora/backend/utils.py @@ -29,6 +29,18 @@ def oxid(title, directors, year='', seriesTitle='', episodeTitle='', season=0, e oxid += hashlib.sha1(oxid_value.encode('utf-8')).hexdigest()[:20] return u"0x" + oxid +def oxdb_id(title, directors=[], year='', season='', episode='', episode_title='', episode_director='', episode_year=''): + # new id function, will replace oxid() + def get_hash(string): + return hashlib.sha1(string.encode('utf-8')).hexdigest().upper() + director = ', '.join(directors) + if not episode: + oxdb_id = get_hash(director)[:8] + get_hash('\n'.join([title, year]))[:8] + else: + oxdb_id = get_hash('\n'.join([director, title, year, season]))[:8] + \ + get_hash('\n'.join([episode, episode_director, episode_title, episode_year]))[:8] + return u'0x' + oxdb_id + def oxdb_directors(director): director = os.path.basename(os.path.dirname(director)) if director.endswith('_'):