[nba] handle format info properly
authorremitamine <remitamine@gmail.com>
Sat, 5 Dec 2015 17:47:15 +0000 (18:47 +0100)
committerremitamine <remitamine@gmail.com>
Sat, 5 Dec 2015 17:47:15 +0000 (18:47 +0100)
youtube_dl/extractor/nba.py

index d8f901b553b9e6fceff2bdcadbc3ed698cff6e67..5a3eb0833049640d5bab95dd7f9faeb96ee74f36 100644 (file)
@@ -77,14 +77,18 @@ class NBAIE(InfoExtractor):
                     formats.extend(f4m_formats)
             else:
                 key = video_file.attrib.get('bitrate')
-                mobj = re.search(r'(\d+)x(\d+)(?:_(\d+))?', key)
-                formats.append({
+                format_info = {
                     'format_id': key,
                     'url': video_url,
-                    'width': int_or_none(mobj.group(1)),
-                    'height': int_or_none(mobj.group(2)),
-                    'tbr': int_or_none(mobj.group(3)),
-                })
+                }
+                mobj = re.search(r'(\d+)x(\d+)(?:_(\d+))?', key)
+                if mobj:
+                    format_info.update({
+                        'width': int_or_none(mobj.group(1)),
+                        'height': int_or_none(mobj.group(2)),
+                        'tbr': int_or_none(mobj.group(3)),
+                    })
+                formats.append(format_info)
         self._sort_formats(formats)
 
         return {