[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / truth.py
blob51d28d15988b4ad00217b9959f2feb130ad964c1
1 from .common import InfoExtractor
2 from ..utils import (
3 clean_html,
4 format_field,
5 int_or_none,
6 strip_or_none,
7 traverse_obj,
8 unified_timestamp,
12 class TruthIE(InfoExtractor):
13 _VALID_URL = r'https?://truthsocial\.com/@[^/]+/posts/(?P<id>\d+)'
14 _TESTS = [
16 'url': 'https://truthsocial.com/@realDonaldTrump/posts/108779000807761862',
17 'md5': '4a5fb1470c192e493d9efd6f19e514d3',
18 'info_dict': {
19 'id': '108779000807761862',
20 'ext': 'qt',
21 'title': 'Truth video #108779000807761862',
22 'timestamp': 1659835827,
23 'upload_date': '20220807',
24 'uploader': 'Donald J. Trump',
25 'uploader_id': 'realDonaldTrump',
26 'uploader_url': 'https://truthsocial.com/@realDonaldTrump',
27 'repost_count': int,
28 'comment_count': int,
29 'like_count': int,
33 'url': 'https://truthsocial.com/@ProjectVeritasAction/posts/108618228543962049',
34 'md5': 'fd47ba68933f9dce27accc52275be9c3',
35 'info_dict': {
36 'id': '108618228543962049',
37 'ext': 'mp4',
38 'title': 'md5:debde7186cf83f60ff7b44dbb9444e35',
39 'description': 'md5:de2fc49045bf92bb8dc97e56503b150f',
40 'timestamp': 1657382637,
41 'upload_date': '20220709',
42 'uploader': 'Project Veritas Action',
43 'uploader_id': 'ProjectVeritasAction',
44 'uploader_url': 'https://truthsocial.com/@ProjectVeritasAction',
45 'repost_count': int,
46 'comment_count': int,
47 'like_count': int,
52 def _real_extract(self, url):
53 video_id = self._match_id(url)
54 status = self._download_json(f'https://truthsocial.com/api/v1/statuses/{video_id}', video_id)
55 uploader_id = strip_or_none(traverse_obj(status, ('account', 'username')))
56 return {
57 'id': video_id,
58 'url': status['media_attachments'][0]['url'],
59 'title': '',
60 'description': strip_or_none(clean_html(status.get('content'))) or None,
61 'timestamp': unified_timestamp(status.get('created_at')),
62 'uploader': strip_or_none(traverse_obj(status, ('account', 'display_name'))),
63 'uploader_id': uploader_id,
64 'uploader_url': format_field(uploader_id, None, 'https://truthsocial.com/@%s'),
65 'repost_count': int_or_none(status.get('reblogs_count')),
66 'like_count': int_or_none(status.get('favourites_count')),
67 'comment_count': int_or_none(status.get('replies_count')),