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