]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | try_get, | |
5 | unified_timestamp, | |
6 | ) | |
7 | ||
8 | ||
9 | class ParlviewIE(InfoExtractor): | |
10 | _WORKING = False | |
11 | _VALID_URL = r'https?://(?:www\.)?parlview\.aph\.gov\.au/(?:[^/]+)?\bvideoID=(?P<id>\d{6})' | |
12 | _TESTS = [{ | |
13 | 'url': 'https://parlview.aph.gov.au/mediaPlayer.php?videoID=542661', | |
14 | 'info_dict': { | |
15 | 'id': '542661', | |
16 | 'ext': 'mp4', | |
17 | 'title': "Australia's Family Law System [Part 2]", | |
18 | 'duration': 5799, | |
19 | 'description': 'md5:7099883b391619dbae435891ca871a62', | |
20 | 'timestamp': 1621430700, | |
21 | 'upload_date': '20210519', | |
22 | 'uploader': 'Joint Committee', | |
23 | }, | |
24 | 'params': { | |
25 | 'skip_download': True, | |
26 | }, | |
27 | }, { | |
28 | 'url': 'https://parlview.aph.gov.au/mediaPlayer.php?videoID=539936', | |
29 | 'only_matching': True, | |
30 | }] | |
31 | _API_URL = 'https://parlview.aph.gov.au/api_v3/1/playback/getUniversalPlayerConfig?videoID=%s&format=json' | |
32 | _MEDIA_INFO_URL = 'https://parlview.aph.gov.au/ajaxPlayer.php?videoID=%s&tabNum=4&action=loadTab' | |
33 | ||
34 | def _real_extract(self, url): | |
35 | video_id = self._match_id(url) | |
36 | webpage = self._download_webpage(url, video_id) | |
37 | media = self._download_json(self._API_URL % video_id, video_id).get('media') | |
38 | timestamp = try_get(media, lambda x: x['timeMap']['source']['timecode_offsets'][0], str) or '/' | |
39 | ||
40 | stream = try_get(media, lambda x: x['renditions'][0], dict) | |
41 | if not stream: | |
42 | self.raise_no_formats('No streams were detected') | |
43 | elif stream.get('streamType') != 'VOD': | |
44 | self.raise_no_formats('Unknown type of stream was detected: "{}"'.format(str(stream.get('streamType')))) | |
45 | formats = self._extract_m3u8_formats(stream['url'], video_id, 'mp4', 'm3u8_native') | |
46 | ||
47 | media_info = self._download_webpage( | |
48 | self._MEDIA_INFO_URL % video_id, video_id, note='Downloading media info', fatal=False) | |
49 | ||
50 | return { | |
51 | 'id': video_id, | |
52 | 'url': url, | |
53 | 'title': self._html_search_regex(r'<h2>([^<]+)<', webpage, 'title', fatal=False), | |
54 | 'formats': formats, | |
55 | 'duration': int_or_none(media.get('duration')), | |
56 | 'timestamp': unified_timestamp(timestamp.split('/', 1)[1].replace('_', ' ')), | |
57 | 'description': self._html_search_regex( | |
58 | r'<div[^>]+class="descripti?on"[^>]*>[^>]+<strong>[^>]+>[^>]+>([^<]+)', | |
59 | webpage, 'description', fatal=False), | |
60 | 'uploader': self._html_search_regex( | |
61 | r'<td>[^>]+>Channel:[^>]+>([^<]+)', media_info, 'channel', fatal=False), | |
62 | 'thumbnail': media.get('staticImage'), | |
63 | } |