]>
Commit | Line | Data |
---|---|---|
0c873df3 AG |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | try_get, | |
6 | unified_strdate, | |
7 | ) | |
8 | ||
9 | ||
10 | class ThreeSpeakIE(InfoExtractor): | |
73f035e1 | 11 | _VALID_URL = r'https?://(?:www\.)?3speak\.tv/watch\?v\=[^/]+/(?P<id>[^/$&#?]+)' |
0c873df3 AG |
12 | |
13 | _TESTS = [{ | |
14 | 'url': 'https://3speak.tv/watch?v=dannyshine/wjgoxyfy', | |
15 | 'info_dict': { | |
16 | 'id': 'wjgoxyfy', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Can People who took the Vax think Critically', | |
19 | 'uploader': 'dannyshine', | |
20 | 'description': 'md5:181aa7ccb304afafa089b5af3bca7a10', | |
21 | 'tags': ['sex', 'covid', 'antinatalism', 'comedy', 'vaccines'], | |
22 | 'thumbnail': 'https://img.3speakcontent.co/wjgoxyfy/thumbnails/default.png', | |
23 | 'upload_date': '20211021', | |
24 | 'duration': 2703.867833, | |
25 | 'filesize': 1620054781, | |
26 | }, | |
add96eb9 | 27 | 'params': {'skip_download': True}, |
0c873df3 AG |
28 | }] |
29 | ||
30 | def _real_extract(self, url): | |
add96eb9 | 31 | video_id = self._match_id(url) |
32 | webpage = self._download_webpage(url, video_id) | |
0c873df3 AG |
33 | json_str = self._html_search_regex(r'JSON\.parse\(\'([^\']+)\'\)', webpage, 'json') |
34 | # The json string itself is escaped. Hence the double parsing | |
add96eb9 | 35 | data_json = self._parse_json(self._parse_json(f'"{json_str}"', video_id), video_id) |
36 | video_json = self._parse_json(data_json['json_metadata'], video_id) | |
0c873df3 AG |
37 | formats, subtitles = [], {} |
38 | og_m3u8 = self._html_search_regex(r'<meta\s?property=\"ogvideo\"\s?content=\"([^\"]+)\">', webpage, 'og m3u8', fatal=False) | |
39 | if og_m3u8: | |
add96eb9 | 40 | https_frmts, https_subs = self._extract_m3u8_formats_and_subtitles(og_m3u8, video_id, fatal=False, m3u8_id='https') |
0c873df3 AG |
41 | formats.extend(https_frmts) |
42 | subtitles = self._merge_subtitles(subtitles, https_subs) | |
43 | ipfs_m3u8 = try_get(video_json, lambda x: x['video']['info']['ipfs']) | |
44 | if ipfs_m3u8: | |
add96eb9 | 45 | ipfs_frmts, ipfs_subs = self._extract_m3u8_formats_and_subtitles( |
46 | f'https://ipfs.3speak.tv/ipfs/{ipfs_m3u8}', video_id, fatal=False, m3u8_id='ipfs') | |
0c873df3 AG |
47 | formats.extend(ipfs_frmts) |
48 | subtitles = self._merge_subtitles(subtitles, ipfs_subs) | |
49 | mp4_file = try_get(video_json, lambda x: x['video']['info']['file']) | |
50 | if mp4_file: | |
51 | formats.append({ | |
add96eb9 | 52 | 'url': f'https://threespeakvideo.b-cdn.net/{video_id}/{mp4_file}', |
0c873df3 AG |
53 | 'ext': 'mp4', |
54 | 'format_id': 'https-mp4', | |
55 | 'duration': try_get(video_json, lambda x: x['video']['info']['duration']), | |
56 | 'filesize': try_get(video_json, lambda x: x['video']['info']['filesize']), | |
57 | 'quality': 11, | |
58 | 'format_note': 'Original file', | |
59 | }) | |
0c873df3 | 60 | return { |
add96eb9 | 61 | 'id': video_id, |
0c873df3 AG |
62 | 'title': data_json.get('title') or data_json.get('root_title'), |
63 | 'uploader': data_json.get('author'), | |
64 | 'description': try_get(video_json, lambda x: x['video']['content']['description']), | |
65 | 'tags': try_get(video_json, lambda x: x['video']['content']['tags']), | |
66 | 'thumbnail': try_get(video_json, lambda x: x['image'][0]), | |
67 | 'upload_date': unified_strdate(data_json.get('created')), | |
68 | 'formats': formats, | |
69 | 'subtitles': subtitles, | |
70 | } | |
71 | ||
72 | ||
73 | class ThreeSpeakUserIE(InfoExtractor): | |
73f035e1 | 74 | _VALID_URL = r'https?://(?:www\.)?3speak\.tv/user/(?P<id>[^/$&?#]+)' |
0c873df3 AG |
75 | |
76 | _TESTS = [{ | |
77 | 'url': 'https://3speak.tv/user/theycallmedan', | |
78 | 'info_dict': { | |
79 | 'id': 'theycallmedan', | |
80 | }, | |
81 | 'playlist_mincount': 115, | |
82 | }] | |
83 | ||
84 | def _real_extract(self, url): | |
add96eb9 | 85 | playlist_id = self._match_id(url) |
86 | webpage = self._download_webpage(url, playlist_id) | |
0c873df3 AG |
87 | entries = [ |
88 | self.url_result( | |
add96eb9 | 89 | f'https://3speak.tv/watch?v={video}', |
0c873df3 AG |
90 | ie=ThreeSpeakIE.ie_key()) |
91 | for video in re.findall(r'data-payout\s?\=\s?\"([^\"]+)\"', webpage) if video | |
92 | ] | |
add96eb9 | 93 | return self.playlist_result(entries, playlist_id) |