1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-04-25 13:25:54 +02:00

[ie/tvplay]: fix broken extractor

This commit is contained in:
lukassup 2024-07-09 18:10:47 +03:00
parent bbf84bf55e
commit 307697b72f

@ -216,8 +216,8 @@ class TVPlayHomeIE(InfoExtractor):
https?:// https?://
(?:tv3?)? (?:tv3?)?
play\.(?:tv3|skaties)\.(?P<country>lv|lt|ee)/ play\.(?:tv3|skaties)\.(?P<country>lv|lt|ee)/
(?P<live>lives/)? (lives/)?
[^?#&]+(?:episode|programme|clip)-(?P<id>\d+) [^?#&]+(?P<category>episode|programme|clip|live)-(?P<id>\d+)
''' '''
_TESTS = [{ _TESTS = [{
'url': 'https://play.tv3.lt/series/gauju-karai-karveliai,serial-2343791/serija-8,episode-2343828', 'url': 'https://play.tv3.lt/series/gauju-karai-karveliai,serial-2343791/serija-8,episode-2343828',
@ -263,18 +263,30 @@ class TVPlayHomeIE(InfoExtractor):
}, { }, {
'url': 'https://tv3play.skaties.lv/clips/tv3-zinas-valsti-lidz-15novembrim-bus-majsede,clip-3464509', 'url': 'https://tv3play.skaties.lv/clips/tv3-zinas-valsti-lidz-15novembrim-bus-majsede,clip-3464509',
'only_matching': True, 'only_matching': True,
}, {
'url': 'https://play.tv3.lt/lives/power-hit-radio,live-4856680',
'only_matching': True,
}, {
'url': 'https://play.tv3.lt/show/tv3-plus,live-4929289',
'only_matching': True,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
country, is_live, video_id = self._match_valid_url(url).groups() country, category, video_id = self._match_valid_url(url).groups()
api_path = 'lives/programmes' if is_live else 'vods' api_path = {
'live': 'lives',
'programme': 'lives/programmes',
}.get(category) or 'vods'
data = self._download_json( data = self._download_json(
urljoin(url, f'/api/products/{api_path}/{video_id}?platform=BROWSER&lang={country.upper()}'), urljoin(url, f'/api/products/{api_path}/{video_id}?platform=BROWSER&lang={country.upper()}'),
video_id) video_id)
video_type = 'CATCHUP' if is_live else 'MOVIE' video_type = {
stream_id = data['programRecordingId'] if is_live else video_id 'live': 'LIVE',
'programme': 'CATCHUP',
}.get(category) or 'MOVIE'
stream_id = data.get('programRecordingId') or video_id
stream = self._download_json( stream = self._download_json(
urljoin(url, f'/api/products/{stream_id}/videos/playlist?videoType={video_type}&platform=BROWSER'), video_id) urljoin(url, f'/api/products/{stream_id}/videos/playlist?videoType={video_type}&platform=BROWSER'), video_id)
formats, subtitles = self._extract_m3u8_formats_and_subtitles( formats, subtitles = self._extract_m3u8_formats_and_subtitles(