]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | float_or_none, | |
4 | js_to_json, | |
5 | parse_iso8601, | |
6 | traverse_obj, | |
7 | url_or_none, | |
8 | ) | |
9 | ||
10 | ||
11 | class AxsIE(InfoExtractor): | |
12 | IE_NAME = 'axs.tv' | |
13 | _VALID_URL = r'https?://(?:www\.)?axs\.tv/(?:channel/(?:[^/?#]+/)+)?video/(?P<id>[^/?#]+)' | |
14 | ||
15 | _TESTS = [{ | |
16 | 'url': 'https://www.axs.tv/video/5f4dc776b70e4f1c194f22ef/', | |
17 | 'md5': '8d97736ae8e50c64df528e5e676778cf', | |
18 | 'info_dict': { | |
19 | 'id': '5f4dc776b70e4f1c194f22ef', | |
20 | 'title': 'Small Town', | |
21 | 'ext': 'mp4', | |
22 | 'description': 'md5:e314d28bfaa227a4d7ec965fae19997f', | |
23 | 'upload_date': '20230602', | |
24 | 'timestamp': 1685729564, | |
25 | 'duration': 1284.216, | |
26 | 'series': 'Rock & Roll Road Trip with Sammy Hagar', | |
27 | 'season': 2, | |
28 | 'episode': '3', | |
29 | 'thumbnail': 'https://images.dotstudiopro.com/5f4e9d330a0c3b295a7e8394', | |
30 | }, | |
31 | }, { | |
32 | 'url': 'https://www.axs.tv/channel/rock-star-interview/video/daryl-hall', | |
33 | 'md5': '300ae795cd8f9984652c0949734ffbdc', | |
34 | 'info_dict': { | |
35 | 'id': '5f488148b70e4f392572977c', | |
36 | 'display_id': 'daryl-hall', | |
37 | 'title': 'Daryl Hall', | |
38 | 'ext': 'mp4', | |
39 | 'description': 'md5:e54ecaa0f4b5683fc9259e9e4b196628', | |
40 | 'upload_date': '20230214', | |
41 | 'timestamp': 1676403615, | |
42 | 'duration': 2570.668, | |
43 | 'series': 'The Big Interview with Dan Rather', | |
44 | 'season': 3, | |
45 | 'episode': '5', | |
46 | 'thumbnail': 'https://images.dotstudiopro.com/5f4d1901f340b50d937cec32', | |
47 | }, | |
48 | }] | |
49 | ||
50 | def _real_extract(self, url): | |
51 | display_id = self._match_id(url) | |
52 | webpage = self._download_webpage(url, display_id) | |
53 | ||
54 | webpage_json_data = self._search_json( | |
55 | r'mountObj\s*=', webpage, 'video ID data', display_id, | |
56 | transform_source=js_to_json) | |
57 | video_id = webpage_json_data['video_id'] | |
58 | company_id = webpage_json_data['company_id'] | |
59 | ||
60 | meta = self._download_json( | |
61 | f'https://api.myspotlight.tv/dotplayer/video/{company_id}/{video_id}', | |
62 | video_id, query={'device_type': 'desktop_web'})['video'] | |
63 | ||
64 | formats = self._extract_m3u8_formats( | |
65 | meta['video_m3u8'], video_id, 'mp4', m3u8_id='hls') | |
66 | ||
67 | subtitles = {} | |
68 | for cc in traverse_obj(meta, ('closeCaption', lambda _, v: url_or_none(v['srtPath']))): | |
69 | subtitles.setdefault(cc.get('srtShortLang') or 'en', []).append( | |
70 | {'ext': cc.get('srtExt'), 'url': cc['srtPath']}) | |
71 | ||
72 | return { | |
73 | 'id': video_id, | |
74 | 'display_id': display_id, | |
75 | 'formats': formats, | |
76 | **traverse_obj(meta, { | |
77 | 'title': ('title', {str}), | |
78 | 'description': ('description', {str}), | |
79 | 'series': ('seriestitle', {str}), | |
80 | 'season': ('season', {int}), | |
81 | 'episode': ('episode', {str}), | |
82 | 'duration': ('duration', {float_or_none}), | |
83 | 'timestamp': ('updated_at', {parse_iso8601}), | |
84 | 'thumbnail': ('thumb', {url_or_none}), | |
85 | }), | |
86 | 'subtitles': subtitles, | |
87 | } |