[common] Improve codecs extraction from m3u8
authorSergey M․ <dstftw@gmail.com>
Mon, 1 Sep 2014 13:13:04 +0000 (20:13 +0700)
committerSergey M․ <dstftw@gmail.com>
Mon, 1 Sep 2014 13:13:04 +0000 (20:13 +0700)
youtube_dl/extractor/common.py

index 8453321c5995a7e752c8653d5f3d5a36fd1e7ee0..929dd1e97efd70e5699dc333d222fe7a97a8de9a 100644 (file)
@@ -677,9 +677,12 @@ class InfoExtractor(object):
                 }
                 codecs = last_info.get('CODECS')
                 if codecs:
-                    video, audio = codecs.split(',')
-                    f['vcodec'] = video.partition('.')[0]
-                    f['acodec'] = audio.partition('.')[0]
+                    # TODO: looks like video codec is not always necessarily goes first
+                    va_codecs = codecs.split(',')
+                    if va_codecs[0]:
+                        f['vcodec'] = va_codecs[0].partition('.')[0]
+                    if len(va_codecs) > 1 and va_codecs[1]:
+                        f['acodec'] = va_codecs[1].partition('.')[0]
                 resolution = last_info.get('RESOLUTION')
                 if resolution:
                     width_str, height_str = resolution.split('x')