mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-01-05 19:10:10 +09:00
[RTV SLO 4D] Removed unnecessary requests, improved formatting
This commit is contained in:
parent
910ef313e1
commit
8e6eca6432
@ -4,7 +4,8 @@ from __future__ import unicode_literals
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
unified_timestamp,
|
||||
try_get, ExtractorError
|
||||
try_get,
|
||||
ExtractorError
|
||||
)
|
||||
|
||||
|
||||
@ -25,37 +26,27 @@ class RTVSLO4DIE(InfoExtractor):
|
||||
}
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
media_id = self._match_id(url)
|
||||
|
||||
embed_url = 'https://4d.rtvslo.si/embed/' + video_id
|
||||
embed_html = self._download_webpage(embed_url, video_id)
|
||||
info_url = 'https://api.rtvslo.si/ava/getRecording/' + media_id + '?client_id=19cc0556a5ee31d0d52a0e30b0696b26'
|
||||
media_info = self._download_json(info_url, media_id)['response']
|
||||
|
||||
client_id = self._search_regex(r'\[\'client\'\] = "(.+?)";', embed_html, 'clientId')
|
||||
|
||||
info_url = 'https://api.rtvslo.si/ava/getRecordingDrm/' + video_id + '?client_id=' + client_id
|
||||
video_info = self._download_json(info_url, video_id)['response']
|
||||
|
||||
if video_info["mediaType"] != "video":
|
||||
raise ExtractorError("Downloading audio is not implemented for this source yet")
|
||||
|
||||
jwt = video_info['jwt']
|
||||
|
||||
media_info_url = 'https://api.rtvslo.si/ava/getMedia/' + video_id + '?client_id=' + client_id + '&jwt=' + jwt
|
||||
media_info = self._download_json(media_info_url, video_id)['response']
|
||||
if media_info['mediaType'] != 'video':
|
||||
raise ExtractorError('Downloading audio is not implemented for this source yet')
|
||||
|
||||
# TODO: Support for audio-only links (like radio shows)
|
||||
# Instead of HLS, an mp3 URL is provided for those in ".mediaFiles[0].streams.https"
|
||||
|
||||
formats = self._extract_m3u8_formats(
|
||||
media_info['addaptiveMedia']['hls'], video_id, 'mp4',
|
||||
media_info['addaptiveMedia']['hls'], media_id, 'mp4',
|
||||
entry_protocol='m3u8_native', m3u8_id='hls')
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': video_info['title'],
|
||||
'description': try_get(video_info, 'description'),
|
||||
'thumbnail': video_info.get('thumbnail_sec'),
|
||||
'timestamp': unified_timestamp(video_info['broadcastDate']),
|
||||
'duration': video_info.get('duration'),
|
||||
'id': media_id,
|
||||
'title': media_info['title'],
|
||||
'description': try_get(media_info, 'description'),
|
||||
'thumbnail': media_info.get('thumbnail_sec'),
|
||||
'timestamp': unified_timestamp(media_info['broadcastDate']),
|
||||
'duration': media_info.get('duration'),
|
||||
'formats': formats,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user