[twitch:stream] Prefer the 'source' format (fixes #4972)

This commit is contained in:
Jaime Marquínez Ferrándiz 2015-02-17 18:55:53 +01:00
parent be24c8697f
commit 4cd95bcbc3
2 changed files with 17 additions and 0 deletions

View file

@ -348,6 +348,12 @@ class TwitchStreamIE(TwitchBaseIE):
'%s/api/channel/hls/%s.m3u8?%s'
% (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'))