0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-30 03:33:02 +00:00

[TBS] Support livestreams (#448)

Authored by: llacb47
This commit is contained in:
LE 2021-06-26 07:44:43 -04:00 committed by GitHub
parent 45261e063b
commit 1e79316e20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -16,7 +16,7 @@
class TBSIE(TurnerBaseIE): class TBSIE(TurnerBaseIE):
_VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com(?P<path>/(?:movies|shows/[^/]+/(?:clips|season-\d+/episode-\d+))/(?P<id>[^/?#]+))' _VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com(?P<path>/(?:movies|watchtnt|shows/[^/]+/(?:clips|season-\d+/episode-\d+))/(?P<id>[^/?#]+))'
_TESTS = [{ _TESTS = [{
'url': 'http://www.tntdrama.com/shows/the-alienist/clips/monster', 'url': 'http://www.tntdrama.com/shows/the-alienist/clips/monster',
'info_dict': { 'info_dict': {
@ -45,7 +45,8 @@ def _real_extract(self, url):
drupal_settings = self._parse_json(self._search_regex( drupal_settings = self._parse_json(self._search_regex(
r'<script[^>]+?data-drupal-selector="drupal-settings-json"[^>]*?>({.+?})</script>', r'<script[^>]+?data-drupal-selector="drupal-settings-json"[^>]*?>({.+?})</script>',
webpage, 'drupal setting'), display_id) webpage, 'drupal setting'), display_id)
video_data = next(v for v in drupal_settings['turner_playlist'] if v.get('url') == path) isLive = 'watchtnt' in path
video_data = next(v for v in drupal_settings['turner_playlist'] if isLive or v.get('url') == path)
media_id = video_data['mediaID'] media_id = video_data['mediaID']
title = video_data['title'] title = video_data['title']
@ -56,7 +57,8 @@ def _real_extract(self, url):
media_id, tokenizer_query, { media_id, tokenizer_query, {
'url': url, 'url': url,
'site_name': site[:3].upper(), 'site_name': site[:3].upper(),
'auth_required': video_data.get('authRequired') == '1', 'auth_required': video_data.get('authRequired') == '1' or isLive,
'is_live': isLive
}) })
thumbnails = [] thumbnails = []
@ -85,5 +87,6 @@ def _real_extract(self, url):
'season_number': int_or_none(video_data.get('season')), 'season_number': int_or_none(video_data.get('season')),
'episode_number': int_or_none(video_data.get('episode')), 'episode_number': int_or_none(video_data.get('episode')),
'thumbnails': thumbnails, 'thumbnails': thumbnails,
'is_live': isLive
}) })
return info return info

View file

@ -221,6 +221,7 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}, ap_data={}, fatal=
} }
def _extract_ngtv_info(self, media_id, tokenizer_query, ap_data=None): def _extract_ngtv_info(self, media_id, tokenizer_query, ap_data=None):
is_live = ap_data.get('is_live')
streams_data = self._download_json( streams_data = self._download_json(
'http://medium.ngtv.io/media/%s/tv' % media_id, 'http://medium.ngtv.io/media/%s/tv' % media_id,
media_id)['media']['tv'] media_id)['media']['tv']
@ -237,11 +238,11 @@ def _extract_ngtv_info(self, media_id, tokenizer_query, ap_data=None):
'http://token.ngtv.io/token/token_spe', 'http://token.ngtv.io/token/token_spe',
m3u8_url, media_id, ap_data or {}, tokenizer_query) m3u8_url, media_id, ap_data or {}, tokenizer_query)
formats.extend(self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
m3u8_url, media_id, 'mp4', m3u8_id='hls', fatal=False)) m3u8_url, media_id, 'mp4', m3u8_id='hls', live=is_live, fatal=False))
duration = float_or_none(stream_data.get('totalRuntime')) duration = float_or_none(stream_data.get('totalRuntime'))
if not chapters: if not chapters and not is_live:
for chapter in stream_data.get('contentSegments', []): for chapter in stream_data.get('contentSegments', []):
start_time = float_or_none(chapter.get('start')) start_time = float_or_none(chapter.get('start'))
chapter_duration = float_or_none(chapter.get('duration')) chapter_duration = float_or_none(chapter.get('duration'))