2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
16 class TVerIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?tver\.jp/(?P<path>(?:corner|episode|feature)/(?P<id>f?\d+))'
18 # videos are only available for 7 days
20 'url': 'https://tver.jp/corner/f0062178',
21 'only_matching': True,
23 'url': 'https://tver.jp/feature/f0062413',
24 'only_matching': True,
26 'url': 'https://tver.jp/episode/79622438',
27 'only_matching': True,
30 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
32 def _real_initialize(self
):
33 self
._TOKEN
= self
._download
_json
(
34 'https://tver.jp/api/access_token.php', None)['token']
36 def _real_extract(self
, url
):
37 path
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
38 main
= self
._download
_json
(
39 'https://api.tver.jp/v4/' + path
, video_id
,
40 query
={'token': self._TOKEN}
)['main']
41 p_id
= main
['publisher_id']
42 service
= remove_start(main
['service'], 'ts_')
44 '_type': 'url_transparent',
45 'description': try_get(main
, lambda x
: x
['note'][0]['text'], compat_str
),
46 'episode_number': int_or_none(try_get(main
, lambda x
: x
['ext']['episode_number'])),
51 'title': main
.get('subtitle') or main
['title'],
52 'url': 'https://i.fod.fujitv.co.jp/plus7/web/%s/%s.html' % (p_id
[:4], p_id
),
53 'ie_key': 'FujiTVFODPlus7',
56 r_id
= main
['reference_id']
57 if service
not in ('tx', 'russia2018', 'sebare2018live', 'gorin'):
60 self
.BRIGHTCOVE_URL_TEMPLATE
% (p_id
, r_id
),
61 {'geo_countries': ['JP']}
)
64 'ie_key': 'BrightcoveNew',