[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / projectveritas.py
blob6f4248526d8c44aa393e15e8f8baf09d80255ee3
1 from .common import InfoExtractor
2 from ..utils import (
3 ExtractorError,
4 traverse_obj,
5 unified_strdate,
9 class ProjectVeritasIE(InfoExtractor):
10 _WORKING = False
11 _VALID_URL = r'https?://(?:www\.)?projectveritas\.com/(?P<type>news|video)/(?P<id>[^/?#]+)'
12 _TESTS = [{
13 'url': 'https://www.projectveritas.com/news/exclusive-inside-the-new-york-and-new-jersey-hospitals-battling-coronavirus/',
14 'info_dict': {
15 'id': '51910aab-365a-5cf1-88f2-8eb1ca5fd3c6',
16 'ext': 'mp4',
17 'title': 'Exclusive: Inside The New York and New Jersey Hospitals Battling Coronavirus',
18 'upload_date': '20200327',
19 'thumbnail': 'md5:6076477fe50b03eb8708be9415e18e1c',
21 }, {
22 'url': 'https://www.projectveritas.com/video/ilhan-omar-connected-ballot-harvester-in-cash-for-ballots-scheme-car-is-full/',
23 'info_dict': {
24 'id': 'c5aab304-a56b-54b1-9f0b-03b77bc5f2f6',
25 'ext': 'mp4',
26 'title': 'Ilhan Omar connected Ballot Harvester in cash-for-ballots scheme: "Car is full" of absentee ballots',
27 'upload_date': '20200927',
28 'thumbnail': 'md5:194b8edf0e2ba64f25500ff4378369a4',
32 def _real_extract(self, url):
33 video_id, video_type = self._match_valid_url(url).group('id', 'type')
34 api_url = f'https://www.projectveritas.com/page-data/{video_type}/{video_id}/page-data.json'
35 data_json = self._download_json(api_url, video_id)['result']['data']
36 main_data = traverse_obj(data_json, 'video', 'post')
37 video_id = main_data['id']
38 thumbnail = traverse_obj(main_data, ('image', 'ogImage', 'src'))
39 mux_asset = traverse_obj(main_data,
40 'muxAsset', ('body', 'json', 'content', ..., 'data', 'target', 'fields', 'muxAsset'),
41 get_all=False, expected_type=dict)
42 if not mux_asset:
43 raise ExtractorError('No video on the provided url.', expected=True)
44 playback_id = traverse_obj(mux_asset, 'playbackId', ('en-US', 'playbackId'))
45 formats = self._extract_m3u8_formats(f'https://stream.mux.com/{playback_id}.m3u8', video_id)
46 return {
47 'id': video_id,
48 'title': main_data['title'],
49 'upload_date': unified_strdate(main_data.get('date')),
50 'thumbnail': thumbnail.replace('//', ''),
51 'formats': formats,