PEP8 fixes
[youtube-dl] / youtube_dl / extractor / twitch.py
index 741df7cbc40b07e277d09f00652e98a32bed7e13..4b0d8988d9cc0f866120d7f31a6facc25d47afec 100644 (file)
@@ -349,6 +349,13 @@ class TwitchStreamIE(TwitchBaseIE):
             % (self._USHER_BASE, channel_id, compat_urllib_parse.urlencode(query).encode('utf-8')),
             channel_id, 'mp4')
 
+        # prefer the 'source' stream, the others are limited to 30 fps
+        def _sort_source(f):
+            if f.get('m3u8_media') is not None and f['m3u8_media'].get('NAME') == 'Source':
+                return 1
+            return 0
+        formats = sorted(formats, key=_sort_source)
+
         view_count = stream.get('viewers')
         timestamp = parse_iso8601(stream.get('created_at'))
 
@@ -379,4 +386,4 @@ class TwitchStreamIE(TwitchBaseIE):
             'view_count': view_count,
             'formats': formats,
             'is_live': True,
-        }
\ No newline at end of file
+        }