[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / axs.py
blob7e91667712397810fdb865656bba184ba4c9a69b
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,
11 class AxsIE(InfoExtractor):
12 IE_NAME = 'axs.tv'
13 _VALID_URL = r'https?://(?:www\.)?axs\.tv/(?:channel/(?:[^/?#]+/)+)?video/(?P<id>[^/?#]+)'
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': 'Season 2',
28 'season_number': 2,
29 'episode': '3',
30 'thumbnail': 'https://images.dotstudiopro.com/5f4e9d330a0c3b295a7e8394',
32 }, {
33 'url': 'https://www.axs.tv/channel/rock-star-interview/video/daryl-hall',
34 'md5': '300ae795cd8f9984652c0949734ffbdc',
35 'info_dict': {
36 'id': '5f488148b70e4f392572977c',
37 'display_id': 'daryl-hall',
38 'title': 'Daryl Hall',
39 'ext': 'mp4',
40 'description': 'md5:e54ecaa0f4b5683fc9259e9e4b196628',
41 'upload_date': '20230214',
42 'timestamp': 1676403615,
43 'duration': 2570.668,
44 'series': 'The Big Interview with Dan Rather',
45 'season': 'Season 3',
46 'season_number': 3,
47 'episode': '5',
48 'thumbnail': 'https://images.dotstudiopro.com/5f4d1901f340b50d937cec32',
52 def _real_extract(self, url):
53 display_id = self._match_id(url)
54 webpage = self._download_webpage(url, display_id)
56 webpage_json_data = self._search_json(
57 r'mountObj\s*=', webpage, 'video ID data', display_id,
58 transform_source=js_to_json)
59 video_id = webpage_json_data['video_id']
60 company_id = webpage_json_data['company_id']
62 meta = self._download_json(
63 f'https://api.myspotlight.tv/dotplayer/video/{company_id}/{video_id}',
64 video_id, query={'device_type': 'desktop_web'})['video']
66 formats = self._extract_m3u8_formats(
67 meta['video_m3u8'], video_id, 'mp4', m3u8_id='hls')
69 subtitles = {}
70 for cc in traverse_obj(meta, ('closeCaption', lambda _, v: url_or_none(v['srtPath']))):
71 subtitles.setdefault(cc.get('srtShortLang') or 'en', []).append(
72 {'ext': cc.get('srtExt'), 'url': cc['srtPath']})
74 return {
75 'id': video_id,
76 'display_id': display_id,
77 'formats': formats,
78 **traverse_obj(meta, {
79 'title': ('title', {str}),
80 'description': ('description', {str}),
81 'series': ('seriestitle', {str}),
82 'season_number': ('season', {int}),
83 'episode': ('episode', {str}),
84 'duration': ('duration', {float_or_none}),
85 'timestamp': ('updated_at', {parse_iso8601}),
86 'thumbnail': ('thumb', {url_or_none}),
87 }),
88 'subtitles': subtitles,