Author: duncan
Date: Sat Dec 23 12:41:01 2006
New Revision: 8794

Modified:
   branches/rel-1/freevo/src/util/misc.py
   branches/rel-1/freevo/src/video/videoitem.py

Log:
[ 1621220 ] Sum length of subitems and manual aspect
Patch from Gorka Olaizola applied


Modified: branches/rel-1/freevo/src/util/misc.py
==============================================================================
--- branches/rel-1/freevo/src/util/misc.py      (original)
+++ branches/rel-1/freevo/src/util/misc.py      Sat Dec 23 12:41:01 2006
@@ -507,6 +507,21 @@
 
         return result
 
+def human_aspect_ratio (width, height):
+    try:
+        ratio = str(round(float(width)/float(height), 2))
+        if ratio[:3] == '1.3':
+            ratio = '4:3'
+        elif ratio[:3] == '1.7':
+            ratio = '16:9'
+        elif ratio[:3] == '2.3':
+            ratio = _('Widescreen')
+    except ValueError:
+        ratio = None
+    
+    return ratio
+
+
 
 class _SynchronizedMethod:
 

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        Sat Dec 23 12:41:01 2006
@@ -188,9 +188,16 @@
         if key == 'geometry' and self.info['width'] and self.info['height']:
             return '%sx%s' % (self.info['width'], self.info['height'])
 
-        if key == 'aspect' and self.info['aspect']:
-            aspect = str(self.info['aspect'])
-            return aspect[:aspect.find(' ')].replace('/', ':')
+        if key == 'aspect':
+            if self.info['aspect']:
+                aspect = str(self.info['aspect'])
+                aspect[:aspect.find(' ')].replace('/', ':')
+            else:
+                if self.info['width'] and self.info['height']:
+                    aspect = util.misc.human_aspect_ratio(self.info['width'], 
self.info['height'])
+
+            if aspect:
+                return aspect
             
         if key == 'runtime':
             length = None
@@ -204,9 +211,29 @@
             if not length:
                 return ''
 
-            if isinstance(length, int) or isinstance(length, float) or \
-                   isinstance(length, long):
-                length = str(int(round(length) / 60))
+            try:
+                total = int(length)
+            except ValueError:
+                length = 0
+                total = 0
+
+            if self.subitems:
+                for s in self.subitems:
+                    if s.info['runtime']:
+                        length = s.info['runtime']
+                    elif s.info['length']:
+                        length = s.info['length']
+                    if not length and hasattr(s, 'length'):
+                        length = s.length
+                    if not length:
+                        continue
+                    try:
+                        total += length
+                    except ValueError:
+                        pass
+
+            length = str(total / 60)
+
             if length.find('min') == -1:
                 length = '%s min' % length
             if length.find('/') > 0:

-------------------------------------------------------------------------
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

Reply via email to