diff options
| author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2015-02-17 18:55:53 +0100 | 
|---|---|---|
| committer | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2015-02-17 18:57:01 +0100 | 
| commit | 4cd95bcbc34d74e506e6158251d50d83697da5fe (patch) | |
| tree | e88fe2371a20b0fab65ed49c74f7dcfd6408b2e4 /youtube_dl/extractor/common.py | |
| parent | be24c8697f51fbc68e2cd99668e675a07a3735de (diff) | |
[twitch:stream] Prefer the 'source' format (fixes #4972)
Diffstat (limited to 'youtube_dl/extractor/common.py')
| -rw-r--r-- | youtube_dl/extractor/common.py | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 4b0ee882c..31599bf52 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -839,6 +839,7 @@ class InfoExtractor(object):              note='Downloading m3u8 information',              errnote='Failed to download m3u8 information')          last_info = None +        last_media= None          kv_rex = re.compile(              r'(?P<key>[a-zA-Z_-]+)=(?P<val>"[^"]+"|[^",]+)(?:,|$)')          for line in m3u8_doc.splitlines(): @@ -849,6 +850,13 @@ class InfoExtractor(object):                      if v.startswith('"'):                          v = v[1:-1]                      last_info[m.group('key')] = v +            elif line.startswith('#EXT-X-MEDIA:'): +                last_media = {} +                for m in kv_rex.finditer(line): +                    v = m.group('val') +                    if v.startswith('"'): +                        v = v[1:-1] +                    last_media[m.group('key')] = v              elif line.startswith('#') or not line.strip():                  continue              else: @@ -877,6 +885,9 @@ class InfoExtractor(object):                      width_str, height_str = resolution.split('x')                      f['width'] = int(width_str)                      f['height'] = int(height_str) +                if last_media is not None: +                    f['m3u8_media'] = last_media +                    last_media = None                  formats.append(f)                  last_info = {}          self._sort_formats(formats) | 
