]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/gettr.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
18 class GettrIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(www\.)?gettr\.com/post/(?P<id>[a-z0-9]+)'
20 _MEDIA_BASE_URL
= 'https://media.gettr.com/'
23 'url': 'https://www.gettr.com/post/pcf6uv838f',
26 'title': 'md5:9086a646bbd06c41c4fe8e52b3c93454',
27 'description': 'md5:be0577f1e4caadc06de4a002da2bf287',
29 'uploader': 'EpochTV',
30 'uploader_id': 'epochtv',
31 'thumbnail': r
're:^https?://.+/out\.jpg',
32 'timestamp': 1632782451058,
36 'url': 'https://gettr.com/post/p4iahp',
39 'title': 'md5:b03c07883db6fbc1aab88877a6c3b149',
40 'description': 'md5:741b7419d991c403196ed2ea7749a39d',
42 'uploader': 'Neues Forum Freiheit',
43 'uploader_id': 'nf_freiheit',
44 'thumbnail': r
're:^https?://.+/out\.jpg',
45 'timestamp': 1626594455017,
50 def _real_extract(self
, url
):
51 post_id
= self
._match
_id
(url
)
52 webpage
= self
._download
_webpage
(url
, post_id
)
54 api_data
= self
._download
_json
(
55 'https://api.gettr.com/u/post/%s?incl="poststats|userinfo"' % post_id
, post_id
)
57 post_data
= try_get(api_data
, lambda x
: x
['result']['data'])
58 user_data
= try_get(api_data
, lambda x
: x
['result']['aux']['uinf'][post_data
['uid']]) or {}
60 if post_data
.get('nfound'):
61 raise ExtractorError(post_data
.get('txt'), expected
=True)
63 title
= description
= str_or_none(
64 post_data
.get('txt') or self
._og
_search
_description
(webpage
))
66 uploader
= str_or_none(
67 user_data
.get('nickname')
68 or remove_end(self
._og
_search
_title
(webpage
), ' on GETTR'))
70 title
= '%s - %s' % (uploader
, title
)
72 if not dict_get(post_data
, ['vid', 'ovid']):
73 raise ExtractorError('There\'s no video in this post.')
75 vid
= post_data
.get('vid')
76 ovid
= post_data
.get('ovid')
78 formats
= self
._extract
_m
3u8_formats
(
79 urljoin(self
._MEDIA
_BASE
_URL
, vid
), post_id
, 'mp4',
80 entry_protocol
='m3u8_native', m3u8_id
='hls') if vid
else []
84 'url': urljoin(self
._MEDIA
_BASE
_URL
, ovid
),
87 'width': int_or_none(post_data
.get('vid_wid')),
88 'height': int_or_none(post_data
.get('vid_hgt')),
89 'source_preference': 1,
93 self
._sort
_formats
(formats
)
98 'description': description
,
99 'thumbnail': url_or_none(
100 urljoin(self
._MEDIA
_BASE
_URL
, post_data
.get('main'))
101 or self
._og
_search
_thumbnail
(webpage
)),
102 'timestamp': int_or_none(post_data
.get('cdate')),
103 'uploader_id': str_or_none(
104 dict_get(user_data
, ['_id', 'username'])
105 or post_data
.get('uid')),
106 'uploader': uploader
,
108 'duration': float_or_none(post_data
.get('vid_dur')),
109 'tags': post_data
.get('htgs'),