]>
Commit | Line | Data |
---|---|---|
695b28af H |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | determine_ext, | |
4 | float_or_none, | |
5 | join_nonempty, | |
6 | traverse_obj, | |
7 | url_or_none, | |
8 | ) | |
9 | ||
10 | ||
11 | class DailyWireBaseIE(InfoExtractor): | |
12 | _JSON_PATH = { | |
13 | 'episode': ('props', 'pageProps', 'episodeData', 'episode'), | |
14 | 'videos': ('props', 'pageProps', 'videoData', 'video'), | |
15 | 'podcasts': ('props', 'pageProps', 'episode'), | |
16 | } | |
17 | ||
18 | def _get_json(self, url): | |
19 | sites_type, slug = self._match_valid_url(url).group('sites_type', 'id') | |
20 | json_data = self._search_nextjs_data(self._download_webpage(url, slug), slug) | |
21 | return slug, traverse_obj(json_data, self._JSON_PATH[sites_type]) | |
22 | ||
23 | ||
24 | class DailyWireIE(DailyWireBaseIE): | |
25 | _VALID_URL = r'https?://(?:www\.)dailywire(?:\.com)/(?P<sites_type>episode|videos)/(?P<id>[\w-]+)' | |
26 | _TESTS = [{ | |
27 | 'url': 'https://www.dailywire.com/episode/1-fauci', | |
28 | 'info_dict': { | |
29 | 'id': 'ckzsl50xnqpy30850in3v4bu7', | |
30 | 'ext': 'mp4', | |
31 | 'display_id': '1-fauci', | |
32 | 'title': '1. Fauci', | |
33 | 'description': 'md5:9df630347ef85081b7e97dd30bc22853', | |
34 | 'thumbnail': 'https://daily-wire-production.imgix.net/episodes/ckzsl50xnqpy30850in3v4bu7/ckzsl50xnqpy30850in3v4bu7-1648237399554.jpg', | |
35 | 'creator': 'Caroline Roberts', | |
36 | 'series_id': 'ckzplm0a097fn0826r2vc3j7h', | |
37 | 'series': 'China: The Enemy Within', | |
add96eb9 | 38 | }, |
695b28af H |
39 | }, { |
40 | 'url': 'https://www.dailywire.com/episode/ep-124-bill-maher', | |
41 | 'info_dict': { | |
42 | 'id': 'cl0ngbaalplc80894sfdo9edf', | |
43 | 'ext': 'mp3', | |
44 | 'display_id': 'ep-124-bill-maher', | |
45 | 'title': 'Ep. 124 - Bill Maher', | |
46 | 'thumbnail': 'https://daily-wire-production.imgix.net/episodes/cl0ngbaalplc80894sfdo9edf/cl0ngbaalplc80894sfdo9edf-1647065568518.jpg', | |
47 | 'creator': 'Caroline Roberts', | |
48 | 'description': 'md5:adb0de584bcfa9c41374999d9e324e98', | |
49 | 'series_id': 'cjzvep7270hp00786l9hwccob', | |
50 | 'series': 'The Sunday Special', | |
add96eb9 | 51 | }, |
695b28af H |
52 | }, { |
53 | 'url': 'https://www.dailywire.com/videos/the-hyperions', | |
54 | 'only_matching': True, | |
55 | }] | |
56 | ||
57 | def _real_extract(self, url): | |
58 | slug, episode_info = self._get_json(url) | |
59 | urls = traverse_obj( | |
60 | episode_info, (('segments', 'videoUrl'), ..., ('video', 'audio')), expected_type=url_or_none) | |
61 | ||
62 | formats, subtitles = [], {} | |
63 | for url in urls: | |
64 | if determine_ext(url) != 'm3u8': | |
65 | formats.append({'url': url}) | |
66 | continue | |
67 | format_, subs_ = self._extract_m3u8_formats_and_subtitles(url, slug) | |
68 | formats.extend(format_) | |
69 | self._merge_subtitles(subs_, target=subtitles) | |
695b28af H |
70 | return { |
71 | 'id': episode_info['id'], | |
72 | 'display_id': slug, | |
73 | 'title': traverse_obj(episode_info, 'title', 'name'), | |
74 | 'description': episode_info.get('description'), | |
7b2c3f47 | 75 | 'creator': join_nonempty(('createdBy', 'firstName'), ('createdBy', 'lastName'), from_dict=episode_info, delim=' '), |
695b28af H |
76 | 'duration': float_or_none(episode_info.get('duration')), |
77 | 'is_live': episode_info.get('isLive'), | |
78 | 'thumbnail': traverse_obj(episode_info, 'thumbnail', 'image', expected_type=url_or_none), | |
79 | 'formats': formats, | |
80 | 'subtitles': subtitles, | |
81 | 'series_id': traverse_obj(episode_info, ('show', 'id')), | |
82 | 'series': traverse_obj(episode_info, ('show', 'name')), | |
83 | } | |
84 | ||
85 | ||
86 | class DailyWirePodcastIE(DailyWireBaseIE): | |
87 | _VALID_URL = r'https?://(?:www\.)dailywire(?:\.com)/(?P<sites_type>podcasts)/(?P<podcaster>[\w-]+/(?P<id>[\w-]+))' | |
88 | _TESTS = [{ | |
89 | 'url': 'https://www.dailywire.com/podcasts/morning-wire/get-ready-for-recession-6-15-22', | |
90 | 'info_dict': { | |
91 | 'id': 'cl4f01d0w8pbe0a98ydd0cfn1', | |
92 | 'ext': 'm4a', | |
93 | 'display_id': 'get-ready-for-recession-6-15-22', | |
94 | 'title': 'Get Ready for Recession | 6.15.22', | |
95 | 'description': 'md5:c4afbadda4e1c38a4496f6d62be55634', | |
96 | 'thumbnail': 'https://daily-wire-production.imgix.net/podcasts/ckx4otgd71jm508699tzb6hf4-1639506575562.jpg', | |
97 | 'duration': 900.117667, | |
add96eb9 | 98 | }, |
695b28af H |
99 | }] |
100 | ||
101 | def _real_extract(self, url): | |
102 | slug, episode_info = self._get_json(url) | |
103 | audio_id = traverse_obj(episode_info, 'audioMuxPlaybackId', 'VUsAipTrBVSgzw73SpC2DAJD401TYYwEp') | |
104 | ||
105 | return { | |
106 | 'id': episode_info['id'], | |
107 | 'url': f'https://stream.media.dailywire.com/{audio_id}/audio.m4a', | |
108 | 'display_id': slug, | |
109 | 'title': episode_info.get('title'), | |
110 | 'duration': float_or_none(episode_info.get('duration')), | |
111 | 'thumbnail': episode_info.get('thumbnail'), | |
112 | 'description': episode_info.get('description'), | |
113 | } |