[extractor/tver] Fix extractor (#4033)

Authored by: Lesmiscore
pull/4042/head
Lesmiscore 3 years ago committed by GitHub
parent 2ae778b8fc
commit 6837633a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,38 +54,41 @@ class TVerIE(InfoExtractor):
video_id = self._match_id(self._search_regex( video_id = self._match_id(self._search_regex(
(r'canonical"\s*href="(https?://tver\.jp/[^"]+)"', r'&link=(https?://tver\.jp/[^?&]+)[?&]'), (r'canonical"\s*href="(https?://tver\.jp/[^"]+)"', r'&link=(https?://tver\.jp/[^?&]+)[?&]'),
webpage, 'url regex')) webpage, 'url regex'))
episode_info = self._download_json(
f'https://platform-api.tver.jp/service/api/v1/callEpisode/{video_id}?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]',
video_id, fatal=False,
query={
'platform_uid': self._PLATFORM_UID,
'platform_token': self._PLATFORM_TOKEN,
}, headers={
'x-tver-platform-type': 'web'
})
episode_content = traverse_obj(
episode_info, ('result', 'episode', 'content')) or {}
video_info = self._download_json( video_info = self._download_json(
f'https://statics.tver.jp/content/episode/{video_id}.json', video_id, f'https://statics.tver.jp/content/episode/{video_id}.json', video_id,
query={'v': '5'}, headers={ query={
'v': str_or_none(episode_content.get('version')) or '5',
}, headers={
'Origin': 'https://tver.jp', 'Origin': 'https://tver.jp',
'Referer': 'https://tver.jp/', 'Referer': 'https://tver.jp/',
}) })
p_id = video_info['video']['accountID'] p_id = video_info['video']['accountID']
r_id = traverse_obj(video_info, ('video', ('videoRefID', 'videoID')), get_all=False) r_id = traverse_obj(video_info, ('video', ('videoRefID', 'videoID')))
if not r_id: if not r_id:
raise ExtractorError('Failed to extract reference ID for Brightcove') raise ExtractorError('Failed to extract reference ID for Brightcove')
if not r_id.isdigit(): if not r_id.isdigit():
r_id = f'ref:{r_id}' r_id = f'ref:{r_id}'
additional_info = self._download_json( episode = strip_or_none(episode_content.get('title'))
f'https://platform-api.tver.jp/service/api/v1/callEpisode/{video_id}?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]', series = str_or_none(episode_content.get('seriesTitle'))
video_id, fatal=False,
query={
'platform_uid': self._PLATFORM_UID,
'platform_token': self._PLATFORM_TOKEN,
}, headers={
'x-tver-platform-type': 'web'
})
additional_content_info = traverse_obj(
additional_info, ('result', 'episode', 'content'), get_all=False) or {}
episode = strip_or_none(additional_content_info.get('title'))
series = str_or_none(additional_content_info.get('seriesTitle'))
title = ( title = (
join_nonempty(series, episode, delim=' ') join_nonempty(series, episode, delim=' ')
or str_or_none(video_info.get('title'))) or str_or_none(video_info.get('title')))
provider = str_or_none(additional_content_info.get('productionProviderName')) provider = str_or_none(episode_content.get('productionProviderName'))
onair_label = str_or_none(additional_content_info.get('broadcastDateLabel')) onair_label = str_or_none(episode_content.get('broadcastDateLabel'))
return { return {
'_type': 'url_transparent', '_type': 'url_transparent',

Loading…
Cancel
Save