1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-29 19:47:54 +01:00

[streamcz] Minor changes

This commit is contained in:
Sergey M. 2014-02-11 10:19:02 +07:00
parent 18395217c4
commit fa78f13302

View File

@ -5,12 +5,13 @@ import re
import json import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import int_or_none
class StreamCZIE(InfoExtractor): class StreamCZIE(InfoExtractor):
_VALID_URL = r'https?://www\.stream\.cz/((?P<category>.+)/)?(?P<videogroup>.+)/(?P<videoid>.+)' _VALID_URL = r'https?://(?:www\.)?stream\.cz/.+/(?P<videoid>.+)'
_TESTS = [{ _TEST = {
'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti', 'url': 'http://www.stream.cz/peklonataliri/765767-ecka-pro-deti',
'md5': '6d3ca61a8d0633c9c542b92fcb936b0c', 'md5': '6d3ca61a8d0633c9c542b92fcb936b0c',
'info_dict': { 'info_dict': {
@ -19,9 +20,9 @@ class StreamCZIE(InfoExtractor):
'title': 'Peklo na talíři: Éčka pro děti', 'title': 'Peklo na talíři: Éčka pro děti',
'description': 'md5:49ace0df986e95e331d0fe239d421519', 'description': 'md5:49ace0df986e95e331d0fe239d421519',
'thumbnail': 'http://im.stream.cz/episode/52961d7e19d423f8f06f0100', 'thumbnail': 'http://im.stream.cz/episode/52961d7e19d423f8f06f0100',
'duration': 256,
}, },
}, }
]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
@ -35,23 +36,23 @@ class StreamCZIE(InfoExtractor):
formats = [] formats = []
for video in jsonData['instances']: for video in jsonData['instances']:
format_id = video['instances'][0]['quality'] for video_format in video['instances']:
format_id = video_format['quality']
if format_id == '240p': if format_id == '240p':
quality = 0 quality = 0
elif format_id == '360p': elif format_id == '360p':
quality = 1 quality = 1
elif format_id == '480p': elif format_id == '480p':
quality = 2 quality = 2
elif format_id == '720p': elif format_id == '720p':
quality = 3 quality = 3
formats.append({ formats.append({
'format_id': format_id, 'format_id': '%s-%s' % (video_format['type'].split('/')[1], format_id),
'url': video['instances'][0]['source'], 'url': video_format['source'],
'quality': quality, 'quality': quality,
'ext': 'mp4', })
})
self._sort_formats(formats) self._sort_formats(formats)
@ -61,4 +62,6 @@ class StreamCZIE(InfoExtractor):
'thumbnail': jsonData['episode_image_original_url'].replace('//', 'http://'), 'thumbnail': jsonData['episode_image_original_url'].replace('//', 'http://'),
'formats': formats, 'formats': formats,
'description': self._og_search_description(webpage), 'description': self._og_search_description(webpage),
'duration': int_or_none(jsonData['duration']),
'view_count': int_or_none(jsonData['stats_total']),
} }