mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 23:26:53 +01:00
[Tvplayhome] Fix extractor (#1357)
Authored by: pukkandan, 18928172992817182 (gustaf)
This commit is contained in:
parent
4e4ba1d75f
commit
896a88c5c6
@ -12,9 +12,9 @@
|
|||||||
determine_ext,
|
determine_ext,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
qualities,
|
qualities,
|
||||||
|
traverse_obj,
|
||||||
try_get,
|
try_get,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
@ -431,77 +431,96 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class TVPlayHomeIE(InfoExtractor):
|
class TVPlayHomeIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:tv3?)?play\.(?:tv3\.lt|skaties\.lv|tv3\.ee)/(?:[^/]+/)*[^/?#&]+-(?P<id>\d+)'
|
_VALID_URL = r'''(?x)
|
||||||
|
https?://
|
||||||
|
(?:tv3?)?
|
||||||
|
play\.(?:tv3|skaties)\.(?P<country>lv|lt|ee)/
|
||||||
|
(?P<live>lives/)?
|
||||||
|
[^?#&]+(?:episode|programme|clip)-(?P<id>\d+)
|
||||||
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://tvplay.tv3.lt/aferistai-n-7/aferistai-10047125/',
|
'url': 'https://play.tv3.lt/series/gauju-karai-karveliai,serial-2343791/serija-8,episode-2343828',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '366367',
|
'id': '2343828',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Aferistai',
|
'title': 'Gaujų karai. Karveliai (2021) | S01E08: Serija 8',
|
||||||
'description': 'Aferistai. Kalėdinė pasaka.',
|
'description': 'md5:f6fcfbb236429f05531131640dfa7c81',
|
||||||
'series': 'Aferistai [N-7]',
|
'duration': 2710,
|
||||||
'season': '1 sezonas',
|
'season': 'Gaujų karai. Karveliai',
|
||||||
'season_number': 1,
|
'season_number': 1,
|
||||||
'duration': 464,
|
'release_year': 2021,
|
||||||
'timestamp': 1394209658,
|
'episode': 'Serija 8',
|
||||||
'upload_date': '20140307',
|
'episode_number': 8,
|
||||||
'age_limit': 18,
|
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': 'm3u8',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tvplay.skaties.lv/vinas-melo-labak/vinas-melo-labak-10280317/',
|
'url': 'https://play.tv3.lt/series/moterys-meluoja-geriau-n-7,serial-2574652/serija-25,episode-3284937',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '3284937',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'season': 'Moterys meluoja geriau [N-7]',
|
||||||
|
'season_number': 14,
|
||||||
|
'release_year': 2021,
|
||||||
|
'episode': 'Serija 25',
|
||||||
|
'episode_number': 25,
|
||||||
|
'title': 'Moterys meluoja geriau [N-7] (2021) | S14|E25: Serija 25',
|
||||||
|
'description': 'md5:c6926e9710f1a126f028fbe121eddb79',
|
||||||
|
'duration': 2440,
|
||||||
|
},
|
||||||
|
'skip': '404'
|
||||||
|
}, {
|
||||||
|
'url': 'https://play.tv3.lt/lives/tv6-lt,live-2838694/optibet-a-lygos-rungtynes-marijampoles-suduva--vilniaus-riteriai,programme-3422014',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tvplay.tv3.ee/cool-d-ga-mehhikosse/cool-d-ga-mehhikosse-10044354/',
|
'url': 'https://tv3play.skaties.lv/series/women-lie-better-lv,serial-1024464/women-lie-better-lv,episode-1038762',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://play.tv3.lt/aferistai-10047125',
|
'url': 'https://play.tv3.ee/series/_,serial-2654462/_,episode-2654474',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://tv3play.skaties.lv/vinas-melo-labak-10280317',
|
'url': 'https://tv3play.skaties.lv/clips/tv3-zinas-valsti-lidz-15novembrim-bus-majsede,clip-3464509',
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'https://play.tv3.ee/cool-d-ga-mehhikosse-10044354',
|
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
country, is_live, video_id = self._match_valid_url(url).groups()
|
||||||
|
|
||||||
asset = self._download_json(
|
api_path = 'lives/programmes' if is_live else 'vods'
|
||||||
urljoin(url, '/sb/public/asset/' + video_id), video_id)
|
data = self._download_json(
|
||||||
|
urljoin(url, f'/api/products/{api_path}/{video_id}?platform=BROWSER&lang={country.upper()}'),
|
||||||
|
video_id)
|
||||||
|
|
||||||
m3u8_url = asset['movie']['contentUrl']
|
video_type = 'CATCHUP' if is_live else 'MOVIE'
|
||||||
video_id = asset['assetId']
|
stream_id = data['programRecordingId'] if is_live else video_id
|
||||||
asset_title = asset['title']
|
stream = self._download_json(
|
||||||
title = asset_title['title']
|
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 = self._extract_m3u8_formats(
|
stream['sources']['HLS'][0]['src'], video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
|
||||||
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnails = None
|
thumbnails = set(traverse_obj(
|
||||||
image_url = asset.get('imageUrl')
|
data, (('galary', 'images', 'artworks'), ..., ..., ('miniUrl', 'mainUrl')), expected_type=url_or_none))
|
||||||
if image_url:
|
|
||||||
thumbnails = [{
|
|
||||||
'url': urljoin(url, image_url),
|
|
||||||
'ext': 'jpg',
|
|
||||||
}]
|
|
||||||
|
|
||||||
metadata = asset.get('metadata') or {}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': self._resolve_title(data),
|
||||||
'description': asset_title.get('summaryLong') or asset_title.get('summaryShort'),
|
'description': traverse_obj(data, 'description', 'lead'),
|
||||||
'thumbnails': thumbnails,
|
'duration': int_or_none(data.get('duration')),
|
||||||
'duration': parse_duration(asset_title.get('runTime')),
|
'season': traverse_obj(data, ('season', 'serial', 'title')),
|
||||||
'series': asset.get('tvSeriesTitle'),
|
'season_number': int_or_none(traverse_obj(data, ('season', 'number'))),
|
||||||
'season': asset.get('tvSeasonTitle'),
|
'episode': data.get('title'),
|
||||||
'season_number': int_or_none(metadata.get('seasonNumber')),
|
'episode_number': int_or_none(data.get('episode')),
|
||||||
'episode': asset_title.get('titleBrief'),
|
'release_year': int_or_none(traverse_obj(data, ('season', 'serial', 'year'))),
|
||||||
'episode_number': int_or_none(metadata.get('episodeNumber')),
|
'thumbnails': [{'url': url, 'ext': 'jpg'} for url in thumbnails],
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _resolve_title(data):
|
||||||
|
return try_get(data, lambda x: (
|
||||||
|
f'{data["season"]["serial"]["title"]} ({data["season"]["serial"]["year"]}) | '
|
||||||
|
f'S{data["season"]["number"]:02d}E{data["episode"]:02d}: {data["title"]}'
|
||||||
|
)) or data.get('title')
|
||||||
|
Loading…
Reference in New Issue
Block a user