[TVer] Extract message for unaired live (#2375)
Closes #2365 Authored by: Lesmiscore
This commit is contained in:
parent
ba1c671d2e
commit
42c5458a02
1 changed files with 14 additions and 8 deletions
|
@ -5,10 +5,11 @@ from __future__ import unicode_literals
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
remove_start,
|
remove_start,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
try_get,
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,13 +39,18 @@ class TVerIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
path, video_id = self._match_valid_url(url).groups()
|
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,
|
'https://api.tver.jp/v4/' + path, video_id,
|
||||||
query={'token': self._TOKEN})['main']
|
query={'token': self._TOKEN})
|
||||||
p_id = main['publisher_id']
|
p_id = traverse_obj(api_response, ('main', 'publisher_id'))
|
||||||
service = remove_start(main['service'], 'ts_')
|
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'):
|
if service not in ('tx', 'russia2018', 'sebare2018live', 'gorin'):
|
||||||
r_id = 'ref:' + r_id
|
r_id = 'ref:' + r_id
|
||||||
bc_url = smuggle_url(
|
bc_url = smuggle_url(
|
||||||
|
@ -53,8 +59,8 @@ class TVerIE(InfoExtractor):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'description': try_get(main, lambda x: x['note'][0]['text'], compat_str),
|
'description': traverse_obj(api_response, ('main', 'note', 0, 'text'), expected_type=compat_str),
|
||||||
'episode_number': int_or_none(try_get(main, lambda x: x['ext']['episode_number'])),
|
'episode_number': int_or_none(traverse_obj(api_response, ('main', 'ext', 'episode_number'), expected_type=compat_str)),
|
||||||
'url': bc_url,
|
'url': bc_url,
|
||||||
'ie_key': 'BrightcoveNew',
|
'ie_key': 'BrightcoveNew',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue