1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2025-02-17 01:17:54 +01:00

[goodgame] Fix format preference, Source by default

This commit is contained in:
Golenitskii K 2017-12-17 14:35:54 +03:00
parent 9ff9c9489d
commit f044e0d631

View File

@ -3,9 +3,12 @@ from __future__ import unicode_literals
import re
from .youtube import YoutubeIE
from .common import InfoExtractor
from ..utils import ExtractorError, int_or_none
from .youtube import YoutubeIE
from ..utils import (
ExtractorError,
int_or_none
)
class GoodgameBaseIE(InfoExtractor):
@ -13,10 +16,10 @@ class GoodgameBaseIE(InfoExtractor):
_API_BASE = 'https://goodgame.ru/api'
_HLS_BASE = 'https://hls.goodgame.ru/hls'
_QUALITIES = {
'Source': '',
'240p': '_240',
'480p': '_480',
'720p': '_720',
'Source': ''
}
_RE_UPLOADER = r'''(?x)
<a[^>]+
@ -103,6 +106,7 @@ class GoodgameStreamIE(GoodgameBaseIE):
'ext': 'mp4',
'protocol': 'm3u8'
})
self._prefer_source(formats)
return {
'id': channel_id,
'title': stream_info.get('title'),
@ -112,6 +116,14 @@ class GoodgameStreamIE(GoodgameBaseIE):
'formats': formats,
}
def _prefer_source(self, formats):
try:
source = next(f for f in formats if f['format_id'] == 'Source')
source['preference'] = 10
except StopIteration:
pass
self._sort_formats(formats)
class GoodgameVideoIE(GoodgameBaseIE):
IE_NAME = 'goodgame:video'