]>
Commit | Line | Data |
---|---|---|
43cf982a BW |
1 | from .common import InfoExtractor |
2 | from .youtube import YoutubeIE | |
43cf982a BW |
3 | from ..utils import ( |
4 | clean_html, | |
5 | format_field, | |
6 | int_or_none, | |
7 | strip_or_none, | |
8 | traverse_obj, | |
9 | unified_timestamp, | |
10 | urlencode_postdata, | |
11 | ) | |
12 | ||
13 | ||
14 | class ParlerIE(InfoExtractor): | |
15 | IE_DESC = 'Posts on parler.com' | |
16 | _VALID_URL = r'https://parler\.com/feed/(?P<id>[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})' | |
17 | _TESTS = [ | |
18 | { | |
19 | 'url': 'https://parler.com/feed/df79fdba-07cc-48fe-b085-3293897520d7', | |
20 | 'md5': '16e0f447bf186bb3cf64de5bbbf4d22d', | |
21 | 'info_dict': { | |
22 | 'id': 'df79fdba-07cc-48fe-b085-3293897520d7', | |
23 | 'ext': 'mp4', | |
24 | 'thumbnail': 'https://bl-images.parler.com/videos/6ce7cdf3-a27a-4d72-bf9c-d3e17ce39a66/thumbnail.jpeg', | |
25 | 'title': 'Parler video #df79fdba-07cc-48fe-b085-3293897520d7', | |
26 | 'description': 'md5:6f220bde2df4a97cbb89ac11f1fd8197', | |
27 | 'timestamp': 1659744000, | |
28 | 'upload_date': '20220806', | |
29 | 'uploader': 'Tulsi Gabbard', | |
30 | 'uploader_id': 'TulsiGabbard', | |
31 | 'uploader_url': 'https://parler.com/TulsiGabbard', | |
32 | 'view_count': int, | |
33 | 'comment_count': int, | |
34 | 'repost_count': int, | |
35 | }, | |
36 | }, | |
37 | { | |
38 | 'url': 'https://parler.com/feed/a7406eb4-91e5-4793-b5e3-ade57a24e287', | |
39 | 'md5': '11687e2f5bb353682cee338d181422ed', | |
40 | 'info_dict': { | |
41 | 'id': 'a7406eb4-91e5-4793-b5e3-ade57a24e287', | |
42 | 'ext': 'mp4', | |
43 | 'thumbnail': 'https://bl-images.parler.com/videos/317827a8-1e48-4cbc-981f-7dd17d4c1183/thumbnail.jpeg', | |
44 | 'title': 'Parler video #a7406eb4-91e5-4793-b5e3-ade57a24e287', | |
45 | 'description': 'This man should run for office', | |
46 | 'timestamp': 1659657600, | |
47 | 'upload_date': '20220805', | |
48 | 'uploader': 'Benny Johnson', | |
49 | 'uploader_id': 'BennyJohnson', | |
50 | 'uploader_url': 'https://parler.com/BennyJohnson', | |
51 | 'view_count': int, | |
52 | 'comment_count': int, | |
53 | 'repost_count': int, | |
54 | }, | |
55 | }, | |
56 | { | |
57 | 'url': 'https://parler.com/feed/f23b85c1-6558-470f-b9ff-02c145f28da5', | |
58 | 'md5': 'eaba1ff4a10fe281f5ce74e930ab2cb4', | |
59 | 'info_dict': { | |
60 | 'id': 'r5vkSaz8PxQ', | |
61 | 'ext': 'mp4', | |
62 | 'thumbnail': 'https://i.ytimg.com/vi_webp/r5vkSaz8PxQ/maxresdefault.webp', | |
63 | 'title': 'Tom MacDonald Names Reaction', | |
64 | 'description': 'md5:33c21f0d35ae6dc2edf3007d6696baea', | |
65 | 'upload_date': '20220716', | |
66 | 'duration': 1267, | |
67 | 'uploader': 'Mahesh Chookolingo', | |
68 | 'uploader_id': 'maheshchookolingo', | |
69 | 'uploader_url': 'http://www.youtube.com/user/maheshchookolingo', | |
70 | 'channel': 'Mahesh Chookolingo', | |
71 | 'channel_id': 'UCox6YeMSY1PQInbCtTaZj_w', | |
72 | 'channel_url': 'https://www.youtube.com/channel/UCox6YeMSY1PQInbCtTaZj_w', | |
73 | 'categories': ['Entertainment'], | |
74 | 'tags': list, | |
75 | 'availability': 'public', | |
76 | 'live_status': 'not_live', | |
77 | 'view_count': int, | |
78 | 'comment_count': int, | |
79 | 'like_count': int, | |
80 | 'channel_follower_count': int, | |
81 | 'age_limit': 0, | |
82 | 'playable_in_embed': True, | |
83 | }, | |
84 | }, | |
85 | ] | |
86 | ||
87 | def _real_extract(self, url): | |
88 | video_id = self._match_id(url) | |
89 | data = self._download_json( | |
90 | 'https://parler.com/open-api/ParleyDetailEndpoint.php', video_id, | |
91 | data=urlencode_postdata({'uuid': video_id}))['data'][0] | |
92 | primary = data['primary'] | |
93 | ||
94 | embed = self._parse_json(primary.get('V2LINKLONG') or '', video_id, fatal=False) | |
95 | if embed: | |
96 | return self.url_result(embed[0], YoutubeIE) | |
97 | ||
98 | return { | |
99 | 'id': video_id, | |
100 | 'url': traverse_obj(primary, ('video_data', 'videoSrc')), | |
101 | 'thumbnail': traverse_obj(primary, ('video_data', 'thumbnailUrl')), | |
102 | 'title': '', | |
103 | 'description': strip_or_none(clean_html(primary.get('full_body'))) or None, | |
104 | 'timestamp': unified_timestamp(primary.get('date_created')), | |
105 | 'uploader': strip_or_none(primary.get('name')), | |
106 | 'uploader_id': strip_or_none(primary.get('username')), | |
107 | 'uploader_url': format_field(strip_or_none(primary.get('username')), None, 'https://parler.com/%s'), | |
108 | 'view_count': int_or_none(primary.get('view_count')), | |
109 | 'comment_count': int_or_none(traverse_obj(data, ('engagement', 'commentCount'))), | |
110 | 'repost_count': int_or_none(traverse_obj(data, ('engagement', 'echoCount'))), | |
111 | } |