Author: duncan
Date: Mon Jan 15 21:45:23 2007
New Revision: 8984
Modified:
branches/rel-1/freevo/src/video/videoitem.py
Log:
[ 1629340 ] Runtime shows "min min" when runtime comes from imdb
Rewritten the runtime code to use a regexp
Modified: branches/rel-1/freevo/src/video/videoitem.py
==============================================================================
--- branches/rel-1/freevo/src/video/videoitem.py (original)
+++ branches/rel-1/freevo/src/video/videoitem.py Mon Jan 15 21:45:23 2007
@@ -223,17 +223,29 @@
if self.info['runtime']:
length = self.info['runtime']
- if not length or length == 'None':
- length = ''
- if length.find('min') == -1:
- length = '%s min' % length
- if length.find('/') > 0:
- length = length[:length.find('/')].rstrip()
- if length.find(':') > 0:
- length = length[length.find(':')+1:]
- if length == '0 min':
- length = ''
- total = length
+ # Assuming that runtime is always a string
+ # Assume that a time 1:40 is hours:minutes
+ # Not sure when a '/' is used
+ p=re.compile('([0-9]+)[:/]*([0-9]*)')
+ m=p.match(length)
+ if m:
+ length = int(m.group(1))
+ if m.group(2):
+ length *= 60 + int(m.group(2))
+ else:
+ length = 0
+ # leaving in the old code for reference
+ #if not length or length == 'None':
+ # length = '0 min'
+ #if length.find('min') == -1:
+ # length = '%s min' % length
+ #if length.find('/') > 0:
+ # length = length[:length.find('/')].rstrip()
+ #if length.find(':') > 0:
+ # length = length[length.find(':')+1:]
+ #if length == '0 min':
+ # length = ''
+ total = "%s min" % str(int(length))
elif self.subitems:
for s in self.subitems:
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog