]>
Commit | Line | Data |
---|---|---|
83465fc4 E |
1 | from .common import InfoExtractor |
2 | from ..utils import bool_or_none, traverse_obj, unified_timestamp, url_or_none | |
3 | ||
4 | ||
5 | class EttuTvIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)' | |
7 | ||
8 | _TESTS = [{ | |
9 | 'url': 'https://www.ettu.tv/en-int/playerpage/1573849', | |
10 | 'md5': '5874b7639a2aa866d1f6c3a4037c7c09', | |
11 | 'info_dict': { | |
12 | 'id': '1573849', | |
13 | 'title': 'Ni Xia Lian - Shao Jieni', | |
14 | 'description': 'ITTF Europe Top 16 Cup', | |
15 | 'timestamp': 1677348600, | |
16 | 'upload_date': '20230225', | |
17 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
18 | 'ext': 'mp4', | |
19 | }, | |
20 | }, { | |
21 | 'url': 'https://www.ettu.tv/en-int/playerpage/1573753', | |
22 | 'md5': '1fc094bf96cf2d5ec0f434d3a6dec9aa', | |
23 | 'info_dict': { | |
24 | 'id': '1573753', | |
25 | 'title': 'Qiu Dang - Jorgic Darko', | |
26 | 'description': 'ITTF Europe Top 16 Cup', | |
27 | 'timestamp': 1677423600, | |
28 | 'upload_date': '20230226', | |
29 | 'thumbnail': r're:^https?://.*\.(?:jpg|png)', | |
30 | 'ext': 'mp4', | |
31 | }, | |
32 | }] | |
33 | ||
34 | def _real_extract(self, url): | |
35 | video_id = self._match_id(url) | |
36 | ||
37 | player_settings = self._download_json( | |
38 | f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={ | |
39 | 'language': 'en', | |
40 | 'showTitle': 'true', | |
41 | 'device': 'desktop', | |
42 | }) | |
43 | ||
71baa490 | 44 | stream_response = self._download_json(player_settings['streamAccess'], video_id, data=b'') |
83465fc4 E |
45 | |
46 | formats, subtitles = self._extract_m3u8_formats_and_subtitles( | |
47 | stream_response['data']['stream'], video_id, 'mp4') | |
48 | ||
49 | return { | |
50 | 'id': video_id, | |
51 | 'formats': formats, | |
52 | 'subtitles': subtitles, | |
53 | **traverse_obj(player_settings, { | |
54 | 'title': 'title', | |
55 | 'description': ('metaInformation', 'competition'), | |
56 | 'thumbnail': ('image', {url_or_none}), | |
57 | 'timestamp': ('date', {unified_timestamp}), | |
58 | 'is_live': ('isLivestream', {bool_or_none}), | |
59 | }) | |
60 | } |