1 from .common
import InfoExtractor
10 class TVerIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?tver\.jp/(?:(?P<type>lp|corner|series|episodes?|feature|tokyo2020/video)/)+(?P<id>[a-zA-Z0-9]+)'
13 'skip': 'videos are only available for 7 days',
14 'url': 'https://tver.jp/episodes/ephss8yveb',
16 'title': '#44 料理と値段と店主にびっくり オモてなしすぎウマい店 2時間SP',
17 'description': 'md5:66985373a66fed8ad3cd595a3cfebb13',
19 'add_ie': ['BrightcoveNew'],
21 'skip': 'videos are only available for 7 days',
22 'url': 'https://tver.jp/lp/episodes/ep6f16g26p',
24 # sorry but this is "correct"
25 'title': '4月11日(月)23時06分 ~ 放送予定',
26 'description': 'md5:4029cc5f4b1e8090dfc5b7bd2bc5cd0b',
28 'add_ie': ['BrightcoveNew'],
30 'url': 'https://tver.jp/corner/f0103888',
31 'only_matching': True,
33 'url': 'https://tver.jp/lp/f0033031',
34 'only_matching': True,
36 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
38 _PLATFORM_TOKEN
= None
40 def _real_initialize(self
):
41 create_response
= self
._download
_json
(
42 'https://platform-api.tver.jp/v2/api/platform_users/browser/create', None,
43 note
='Creating session', data
=b
'device_type=pc', headers
={
44 'Origin': 'https://s.tver.jp',
45 'Referer': 'https://s.tver.jp/',
46 'Content-Type': 'application/x-www-form-urlencoded',
48 self
._PLATFORM
_UID
= traverse_obj(create_response
, ('result', 'platform_uid'))
49 self
._PLATFORM
_TOKEN
= traverse_obj(create_response
, ('result', 'platform_token'))
51 def _real_extract(self
, url
):
52 video_id
, video_type
= self
._match
_valid
_url
(url
).group('id', 'type')
53 if video_type
not in {'series', 'episodes'}
:
54 webpage
= self
._download
_webpage
(url
, video_id
, note
='Resolving to new URL')
55 video_id
= self
._match
_id
(self
._search
_regex
(
56 (r
'canonical"\s*href="(https?://tver\.jp/[^"]+)"', r
'&link=(https?://tver\.jp/[^?&]+)[?&]'),
57 webpage
, 'url regex'))
58 video_info
= self
._download
_json
(
59 f
'https://statics.tver.jp/content/episode/{video_id}.json', video_id
,
60 query
={'v': '5'}
, headers
={
61 'Origin': 'https://tver.jp',
62 'Referer': 'https://tver.jp/',
64 p_id
= video_info
['video']['accountID']
65 r_id
= traverse_obj(video_info
, ('video', ('videoRefID', 'videoID')), get_all
=False)
67 raise ExtractorError('Failed to extract reference ID for Brightcove')
68 if not r_id
.isdigit():
71 additional_info
= self
._download
_json
(
72 f
'https://platform-api.tver.jp/service/api/v1/callEpisode/{video_id}?require_data=mylist,later[epefy106ur],good[epefy106ur],resume[epefy106ur]',
73 video_id
, fatal
=False,
75 'platform_uid': self
._PLATFORM
_UID
,
76 'platform_token': self
._PLATFORM
_TOKEN
,
78 'x-tver-platform-type': 'web'
82 '_type': 'url_transparent',
83 'title': str_or_none(video_info
.get('title')),
84 'description': str_or_none(video_info
.get('description')),
86 self
.BRIGHTCOVE_URL_TEMPLATE
% (p_id
, r_id
), {'geo_countries': ['JP']}
),
87 'series': traverse_obj(
88 additional_info
, ('result', ('episode', 'series'), 'content', ('seriesTitle', 'title')),
90 'ie_key': 'BrightcoveNew',