]>
Commit | Line | Data |
---|---|---|
1 | import functools | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from .youtube import YoutubeIE | |
5 | from ..utils import ( | |
6 | clean_html, | |
7 | int_or_none, | |
8 | strip_or_none, | |
9 | traverse_obj, | |
10 | unified_timestamp, | |
11 | urljoin, | |
12 | ) | |
13 | ||
14 | ||
15 | class ParlerIE(InfoExtractor): | |
16 | IE_DESC = 'Posts on parler.com' | |
17 | _VALID_URL = r'https?://parler\.com/feed/(?P<id>[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})' | |
18 | _TESTS = [ | |
19 | { | |
20 | 'url': 'https://parler.com/feed/df79fdba-07cc-48fe-b085-3293897520d7', | |
21 | 'md5': '16e0f447bf186bb3cf64de5bbbf4d22d', | |
22 | 'info_dict': { | |
23 | 'id': 'df79fdba-07cc-48fe-b085-3293897520d7', | |
24 | 'ext': 'mp4', | |
25 | 'thumbnail': 'https://bl-images.parler.com/videos/6ce7cdf3-a27a-4d72-bf9c-d3e17ce39a66/thumbnail.jpeg', | |
26 | 'title': 'Parler video #df79fdba-07cc-48fe-b085-3293897520d7', | |
27 | 'description': 'md5:6f220bde2df4a97cbb89ac11f1fd8197', | |
28 | 'timestamp': 1659785481, | |
29 | 'upload_date': '20220806', | |
30 | 'uploader': 'Tulsi Gabbard', | |
31 | 'uploader_id': 'TulsiGabbard', | |
32 | 'uploader_url': 'https://parler.com/TulsiGabbard', | |
33 | 'view_count': int, | |
34 | 'comment_count': int, | |
35 | 'repost_count': int, | |
36 | }, | |
37 | }, | |
38 | { | |
39 | 'url': 'https://parler.com/feed/f23b85c1-6558-470f-b9ff-02c145f28da5', | |
40 | 'md5': 'eaba1ff4a10fe281f5ce74e930ab2cb4', | |
41 | 'info_dict': { | |
42 | 'id': 'r5vkSaz8PxQ', | |
43 | 'ext': 'mp4', | |
44 | 'live_status': 'not_live', | |
45 | 'comment_count': int, | |
46 | 'duration': 1267, | |
47 | 'like_count': int, | |
48 | 'channel_follower_count': int, | |
49 | 'channel_id': 'UCox6YeMSY1PQInbCtTaZj_w', | |
50 | 'upload_date': '20220716', | |
51 | 'thumbnail': 'https://i.ytimg.com/vi/r5vkSaz8PxQ/maxresdefault.jpg', | |
52 | 'tags': 'count:17', | |
53 | 'availability': 'public', | |
54 | 'categories': ['Entertainment'], | |
55 | 'playable_in_embed': True, | |
56 | 'channel': 'Who Knows What! With Mahesh & Friends', | |
57 | 'title': 'Tom MacDonald Names Reaction', | |
58 | 'uploader': 'Who Knows What! With Mahesh & Friends', | |
59 | 'uploader_id': '@maheshchookolingo', | |
60 | 'age_limit': 0, | |
61 | 'description': 'md5:33c21f0d35ae6dc2edf3007d6696baea', | |
62 | 'channel_url': 'https://www.youtube.com/channel/UCox6YeMSY1PQInbCtTaZj_w', | |
63 | 'view_count': int, | |
64 | 'uploader_url': 'http://www.youtube.com/@maheshchookolingo', | |
65 | }, | |
66 | }, | |
67 | ] | |
68 | ||
69 | def _real_extract(self, url): | |
70 | video_id = self._match_id(url) | |
71 | data = self._download_json(f'https://api.parler.com/v0/public/parleys/{video_id}', | |
72 | video_id)['data'] | |
73 | if data.get('link'): | |
74 | return self.url_result(data['link'], YoutubeIE) | |
75 | ||
76 | return { | |
77 | 'id': video_id, | |
78 | 'title': strip_or_none(data.get('title')) or '', | |
79 | **traverse_obj(data, { | |
80 | 'url': ('video', 'videoSrc'), | |
81 | 'thumbnail': ('video', 'thumbnailUrl'), | |
82 | 'description': ('body', {clean_html}), | |
83 | 'timestamp': ('date_created', {unified_timestamp}), | |
84 | 'uploader': ('user', 'name', {strip_or_none}), | |
85 | 'uploader_id': ('user', 'username', {str}), | |
86 | 'uploader_url': ('user', 'username', {functools.partial(urljoin, 'https://parler.com/')}), | |
87 | 'view_count': ('views', {int_or_none}), | |
88 | 'comment_count': ('total_comments', {int_or_none}), | |
89 | 'repost_count': ('echos', {int_or_none}), | |
90 | }) | |
91 | } |