]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/epoch.py
[extractor/swearnet] Add extractor (#5371)
[yt-dlp.git] / yt_dlp / extractor / epoch.py
CommitLineData
f8c7ba99
TA
1from .common import InfoExtractor
2
3
4class EpochIE(InfoExtractor):
5 _VALID_URL = r'https?://www.theepochtimes\.com/[\w-]+_(?P<id>\d+).html'
6 _TESTS = [
7 {
8 'url': 'https://www.theepochtimes.com/they-can-do-audio-video-physical-surveillance-on-you-24h-365d-a-year-rex-lee-on-intrusive-apps_4661688.html',
9 'info_dict': {
10 'id': 'a3dd732c-4750-4bc8-8156-69180668bda1',
11 'ext': 'mp4',
12 'title': '‘They Can Do Audio, Video, Physical Surveillance on You 24H/365D a Year’: Rex Lee on Intrusive Apps',
13 }
14 },
15 {
16 'url': 'https://www.theepochtimes.com/the-communist-partys-cyberattacks-on-america-explained-rex-lee-talks-tech-hybrid-warfare_4342413.html',
17 'info_dict': {
18 'id': '276c7f46-3bbf-475d-9934-b9bbe827cf0a',
19 'ext': 'mp4',
20 'title': 'The Communist Party’s Cyberattacks on America Explained; Rex Lee Talks Tech Hybrid Warfare',
21 }
22 },
23 {
24 'url': 'https://www.theepochtimes.com/kash-patel-a-6-year-saga-of-government-corruption-from-russiagate-to-mar-a-lago_4690250.html',
25 'info_dict': {
26 'id': 'aa9ceecd-a127-453d-a2de-7153d6fd69b6',
27 'ext': 'mp4',
28 'title': 'Kash Patel: A ‘6-Year-Saga’ of Government Corruption, From Russiagate to Mar-a-Lago',
29 }
30 },
31 ]
32
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35 webpage = self._download_webpage(url, video_id)
36
37 youmaker_video_id = self._search_regex(r'data-trailer="[\w-]+" data-id="([\w-]+)"', webpage, 'url')
38 formats, subtitles = self._extract_m3u8_formats_and_subtitles(
39 f'http://vs1.youmaker.com/assets/{youmaker_video_id}/playlist.m3u8', video_id, 'mp4', m3u8_id='hls')
40
41 return {
42 'id': youmaker_video_id,
43 'formats': formats,
44 'subtitles': subtitles,
45 'title': self._html_extract_title(webpage)
46 }