[appletrailers] Support height-less videos
authorPhilipp Hagemeister <phihag@phihag.de>
Sun, 10 Aug 2014 11:04:45 +0000 (13:04 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Sun, 10 Aug 2014 11:04:45 +0000 (13:04 +0200)
youtube_dl/extractor/appletrailers.py
youtube_dl/utils.py

index dc8657b67c9850c1676af737f319cb4c06bad6d6..4359b88d1b7057944beb126eb8a1c82dbb818758 100644 (file)
@@ -6,6 +6,7 @@ import json
 from .common import InfoExtractor
 from ..utils import (
     compat_urlparse,
+    int_or_none,
 )
 
 
@@ -110,8 +111,8 @@ class AppleTrailersIE(InfoExtractor):
                 formats.append({
                     'url': format_url,
                     'format': format['type'],
-                    'width': format['width'],
-                    'height': int(format['height']),
+                    'width': int_or_none(format['width']),
+                    'height': int_or_none(format['height']),
                 })
 
             self._sort_formats(formats)
index 9b94407f41f10cd90f6249583a2ffd9583002fee..65b492fb336e4e26f7193377c48282a3b5464939 100644 (file)
@@ -1273,8 +1273,11 @@ def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1):
     if get_attr:
         if v is not None:
             v = getattr(v, get_attr, None)
+    if v == '':
+        v = None
     return default if v is None else (int(v) * invscale // scale)
 
+
 def str_or_none(v, default=None):
     return default if v is None else compat_str(v)