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