1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-22 10:11:52 +00:00

[rtvs] Fixed extractor for Slovak television and radio

This commit is contained in:
Jastrab 2022-01-15 21:08:06 +01:00
parent 5014bd67c2
commit 63af7465cc

View file

@ -1,7 +1,13 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
url_or_none,
determine_ext
)
class RTVSIE(InfoExtractor): class RTVSIE(InfoExtractor):
@ -26,7 +32,8 @@ class RTVSIE(InfoExtractor):
'id': '63118', 'id': '63118',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Amaro Džives - Náš deň', 'title': 'Amaro Džives - Náš deň',
'description': 'Galavečer pri príležitosti Medzinárodného dňa Rómov.' 'description':
'Galavečer pri príležitosti Medzinárodného dňa Rómov.'
}, },
'params': { 'params': {
'skip_download': True, 'skip_download': True,
@ -36,12 +43,66 @@ class RTVSIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) if url.find('/radio/') != -1:
a2 = url.split('/')[-1]
a1 = url.split('/')[-2]
embed = self._download_webpage(
"https://www.rtvs.sk/embed/radio/archive/%s/%s" % (a1, a2),
video_id)
audio_id = re.search('audio5f.json?id=(?P<id>[^\"]+)', embed)
audio_id = audio_id.group('id')
info = self._download_json(
"https://www.rtvs.sk/json/audio5f.json?id=%s" % audio_id,
audio_id)
playlist_url = self._search_regex( formats = []
r'playlist["\']?\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, formats.append({
'playlist url', group='url') 'url': info['playlist'][0]['sources'][0]['src'],
'format_id': None,
'height': 0
})
info = info['playlist'][0]
return {
'id': audio_id,
'title': info.get('title'),
'thumbnail': info.get('image'),
'formats': formats
}
else:
info = self._download_json(
"https://www.rtvs.sk/json/archive5f.json?id=%s" % video_id,
video_id)
info = info.get('clip')
data = self._download_json( formats = []
playlist_url, video_id, 'Downloading playlist')[0] for format_id, format_list in info.items():
return self._parse_jwplayer_data(data, video_id=video_id) if not isinstance(format_list, list):
format_list = [format_list]
for format_dict in format_list:
if not isinstance(format_dict, dict):
continue
format_url = url_or_none(format_dict.get('src'))
format_type = format_dict.get('type')
ext = determine_ext(format_url)
if (format_type == 'application/x-mpegURL'
or format_id == 'HLS' or ext == 'm3u8'):
formats.extend(self._extract_m3u8_formats(
format_url, video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='hls',
fatal=False))
elif (format_type == 'application/dash+xml'
or format_id == 'DASH' or ext == 'mpd'):
pass
else:
formats.append({
'url': format_url,
})
formats = sorted(formats, key=lambda i: i['tbr'])
dt = info.get('datetime_create')
return {
'id': video_id,
'title': info.get('title') + '-' + dt[:10],
'thumbnail': info.get('image'),
'description': info.get('description'),
'formats': formats
}