mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 08:19:57 +01:00
[TVer] Extract message for unaired live (#2375)
Closes #2365 Authored by: Lesmiscore
This commit is contained in:
parent
ba1c671d2e
commit
42c5458a02
@ -5,10 +5,11 @@
|
||||
from .common import InfoExtractor
|
||||
from ..compat import compat_str
|
||||
from ..utils import (
|
||||
ExtractorError,
|
||||
int_or_none,
|
||||
remove_start,
|
||||
smuggle_url,
|
||||
try_get,
|
||||
traverse_obj,
|
||||
)
|
||||
|
||||
|
||||
@ -38,13 +39,18 @@ def _real_initialize(self):
|
||||
|
||||
def _real_extract(self, url):
|
||||
path, video_id = self._match_valid_url(url).groups()
|
||||
main = self._download_json(
|
||||
api_response = self._download_json(
|
||||
'https://api.tver.jp/v4/' + path, video_id,
|
||||
query={'token': self._TOKEN})['main']
|
||||
p_id = main['publisher_id']
|
||||
service = remove_start(main['service'], 'ts_')
|
||||
query={'token': self._TOKEN})
|
||||
p_id = traverse_obj(api_response, ('main', 'publisher_id'))
|
||||
if not p_id:
|
||||
error_msg, expected = traverse_obj(api_response, ('episode', 0, 'textbar', 0, ('text', 'longer')), get_all=False), True
|
||||
if not error_msg:
|
||||
error_msg, expected = 'Failed to extract publisher ID', False
|
||||
raise ExtractorError(error_msg, expected=expected)
|
||||
service = remove_start(traverse_obj(api_response, ('main', 'service')), 'ts_')
|
||||
|
||||
r_id = main['reference_id']
|
||||
r_id = traverse_obj(api_response, ('main', 'reference_id'))
|
||||
if service not in ('tx', 'russia2018', 'sebare2018live', 'gorin'):
|
||||
r_id = 'ref:' + r_id
|
||||
bc_url = smuggle_url(
|
||||
@ -53,8 +59,8 @@ def _real_extract(self, url):
|
||||
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'description': try_get(main, lambda x: x['note'][0]['text'], compat_str),
|
||||
'episode_number': int_or_none(try_get(main, lambda x: x['ext']['episode_number'])),
|
||||
'description': traverse_obj(api_response, ('main', 'note', 0, 'text'), expected_type=compat_str),
|
||||
'episode_number': int_or_none(traverse_obj(api_response, ('main', 'ext', 'episode_number'), expected_type=compat_str)),
|
||||
'url': bc_url,
|
||||
'ie_key': 'BrightcoveNew',
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user