mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
10 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
import json
|
||
|
|
||
|
from .common import InfoExtractor
|
||
|
from ..utils import (
|
||
|
determine_ext,
|
||
|
int_or_none,
|
||
|
js_to_json,
|
||
|
)
|
||
|
|
||
|
|
||
|
class MuenchenTVIE(InfoExtractor):
|
||
|
_VALID_URL = r'https?://(?:www\.)?muenchen\.tv/livestream'
|
||
|
IE_DESC = 'münchen.tv'
|
||
|
_TEST = {
|
||
|
'url': 'http://www.muenchen.tv/livestream/',
|
||
|
'info_dict': {
|
||
|
'id': '5334',
|
||
|
'display_id': 'live',
|
||
|
'ext': 'mp4',
|
||
|
'title': 're:^münchen.tv-Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
||
|
'is_live': True,
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$'
|
||
10 years ago
|
},
|
||
|
'params': {
|
||
|
'skip_download': True,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
display_id = 'live'
|
||
|
webpage = self._download_webpage(url, display_id)
|
||
|
|
||
10 years ago
|
title = self._live_title(self._og_search_title(webpage))
|
||
10 years ago
|
|
||
|
data_js = self._search_regex(
|
||
8 years ago
|
r'(?s)\nplaylist:\s*(\[.*?}\]),',
|
||
10 years ago
|
webpage, 'playlist configuration')
|
||
|
data_json = js_to_json(data_js)
|
||
|
data = json.loads(data_json)[0]
|
||
|
|
||
|
video_id = data['mediaid']
|
||
|
thumbnail = data.get('image')
|
||
|
|
||
|
formats = []
|
||
|
for format_num, s in enumerate(data['sources']):
|
||
|
ext = determine_ext(s['file'], None)
|
||
|
label_str = s.get('label')
|
||
|
if label_str is None:
|
||
|
label_str = '_%d' % format_num
|
||
|
|
||
|
if ext is None:
|
||
|
format_id = label_str
|
||
|
else:
|
||
|
format_id = '%s-%s' % (ext, label_str)
|
||
|
|
||
|
formats.append({
|
||
|
'url': s['file'],
|
||
|
'tbr': int_or_none(s.get('label')),
|
||
|
'ext': 'mp4',
|
||
|
'format_id': format_id,
|
||
|
'preference': -100 if '.smil' in s['file'] else 0,
|
||
|
})
|
||
|
self._sort_formats(formats)
|
||
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
|
'display_id': display_id,
|
||
|
'title': title,
|
||
|
'formats': formats,
|
||
|
'is_live': True,
|
||
10 years ago
|
'thumbnail': thumbnail,
|
||
10 years ago
|
}
|