]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | ExtractorError, | |
4 | int_or_none, | |
5 | parse_qs, | |
6 | time_seconds, | |
7 | traverse_obj, | |
8 | ) | |
9 | ||
10 | ||
11 | class PIAULIZAPortalIE(InfoExtractor): | |
12 | IE_DESC = 'ulizaportal.jp - PIA LIVE STREAM' | |
13 | _VALID_URL = r'https?://(?:www\.)?ulizaportal\.jp/pages/(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})' | |
14 | _TESTS = [{ | |
15 | 'url': 'https://ulizaportal.jp/pages/005f18b7-e810-5618-cb82-0987c5755d44', | |
16 | 'info_dict': { | |
17 | 'id': '005f18b7-e810-5618-cb82-0987c5755d44', | |
18 | 'title': 'プレゼンテーションプレイヤーのサンプル', | |
19 | 'live_status': 'not_live', | |
20 | }, | |
21 | 'params': { | |
22 | 'skip_download': True, | |
23 | 'ignore_no_formats_error': True, | |
24 | }, | |
25 | }, { | |
26 | 'url': 'https://ulizaportal.jp/pages/005e1b23-fe93-5780-19a0-98e917cc4b7d?expires=4102412400&signature=f422a993b683e1068f946caf406d211c17d1ef17da8bef3df4a519502155aa91&version=1', | |
27 | 'info_dict': { | |
28 | 'id': '005e1b23-fe93-5780-19a0-98e917cc4b7d', | |
29 | 'title': '【確認用】視聴サンプルページ(ULIZA)', | |
30 | 'live_status': 'not_live', | |
31 | }, | |
32 | 'params': { | |
33 | 'skip_download': True, | |
34 | 'ignore_no_formats_error': True, | |
35 | }, | |
36 | }] | |
37 | ||
38 | def _real_extract(self, url): | |
39 | video_id = self._match_id(url) | |
40 | ||
41 | expires = int_or_none(traverse_obj(parse_qs(url), ('expires', 0))) | |
42 | if expires and expires <= time_seconds(): | |
43 | raise ExtractorError('The link is expired.', video_id=video_id, expected=True) | |
44 | ||
45 | webpage = self._download_webpage(url, video_id) | |
46 | ||
47 | player_data = self._download_webpage( | |
48 | self._search_regex( | |
49 | r'<script [^>]*\bsrc="(https://player-api\.p\.uliza\.jp/v1/players/[^"]+)"', | |
50 | webpage, 'player data url'), | |
51 | video_id, headers={'Referer': 'https://ulizaportal.jp/'}, | |
52 | note='Fetching player data', errnote='Unable to fetch player data') | |
53 | ||
54 | formats = self._extract_m3u8_formats( | |
55 | self._search_regex( | |
56 | r'["\'](https://vms-api\.p\.uliza\.jp/v1/prog-index\.m3u8[^"\']+)', player_data, | |
57 | 'm3u8 url', default=None), | |
58 | video_id, fatal=False) | |
59 | m3u8_type = self._search_regex( | |
60 | r'/hls/(dvr|video)/', traverse_obj(formats, (0, 'url')), 'm3u8 type', default=None) | |
61 | ||
62 | return { | |
63 | 'id': video_id, | |
64 | 'title': self._html_extract_title(webpage), | |
65 | 'formats': formats, | |
66 | 'live_status': { | |
67 | 'video': 'is_live', | |
68 | 'dvr': 'was_live', # short-term archives | |
69 | }.get(m3u8_type, 'not_live'), # VOD or long-term archives | |
70 | } |