3 from .common
import InfoExtractor
14 class GabTVIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://tv\.gab\.com/channel/[^/]+/view/(?P<id>[a-z0-9-]+)'
17 'url': 'https://tv.gab.com/channel/wurzelroot/view/why-was-america-in-afghanistan-61217eacea5665de450d0488',
19 'id': '61217eacea5665de450d0488',
21 'title': 'WHY WAS AMERICA IN AFGHANISTAN - AMERICA FIRST AGAINST AMERICAN OLIGARCHY',
22 'uploader': 'Wurzelroot',
23 'uploader_id': '608fb0a85738fd1974984f7d',
24 'thumbnail': 'https://tv.gab.com/image/61217eacea5665de450d0488',
28 def _real_extract(self
, url
):
29 id = self
._match
_id
(url
).split('-')[-1]
30 webpage
= self
._download
_webpage
(url
, id)
31 channel_id
= self
._search
_regex
(r
'data-channel-id=\"(?P<channel_id>[^\"]+)', webpage
, 'channel_id')
32 channel_name
= self
._search
_regex
(r
'data-channel-name=\"(?P<channel_id>[^\"]+)', webpage
, 'channel_name')
33 title
= self
._search
_regex
(r
'data-episode-title=\"(?P<channel_id>[^\"]+)', webpage
, 'title')
34 view_key
= self
._search
_regex
(r
'data-view-key=\"(?P<channel_id>[^\"]+)', webpage
, 'view_key')
35 description
= clean_html(
36 self
._html
_search
_regex
(self
._meta
_regex
('description'), webpage
, 'description', group
='content')) or None
37 available_resolutions
= re
.findall(r
'<a\ data-episode-id=\"%s\"\ data-resolution=\"(?P<resolution>[^\"]+)' % id,
41 for resolution
in available_resolutions
:
43 'url': f
'https://tv.gab.com/media/{id}?viewKey={view_key}&r={resolution}',
44 'format_id': resolution
,
49 if 'audio-' in resolution
:
50 frmt
['abr'] = str_to_int(resolution
.replace('audio-', ''))
54 frmt
['height'] = str_to_int(resolution
.replace('p', ''))
61 'description': description
,
62 'uploader': channel_name
,
63 'uploader_id': channel_id
,
64 'thumbnail': f
'https://tv.gab.com/image/{id}',
68 class GabIE(InfoExtractor
):
69 _VALID_URL
= r
'https?://(?:www\.)?gab\.com/[^/]+/posts/(?P<id>\d+)'
71 'url': 'https://gab.com/SomeBitchIKnow/posts/107163961867310434',
72 'md5': '8ca34fb00f1e1033b5c5988d79ec531d',
74 'id': '107163961867310434-0',
77 'uploader_id': '946600',
78 'uploader': 'SomeBitchIKnow',
79 'description': 'md5:204055fafd5e1a519f5d6db953567ca3',
80 'timestamp': 1635192289,
81 'upload_date': '20211025',
84 'url': 'https://gab.com/TheLonelyProud/posts/107045884469287653',
85 'md5': 'f9cefcfdff6418e392611a828d47839d',
87 'id': '107045884469287653-0',
89 'title': 'Jody Sadowski on Gab',
90 'uploader_id': '1390705',
91 'timestamp': 1633390571,
92 'upload_date': '20211004',
93 'uploader': 'TheLonelyProud',
97 def _real_extract(self
, url
):
98 post_id
= self
._match
_id
(url
)
99 json_data
= self
._download
_json
(f
'https://gab.com/api/v1/statuses/{post_id}', post_id
)
102 for idx
, media
in enumerate(json_data
['media_attachments']):
103 if media
.get('type') not in ('video', 'gifv'):
105 metadata
= media
['meta']
107 'acodec': parse_codecs(metadata
.get('audio_encode')).get('acodec'),
108 'asr': int_or_none((metadata
.get('audio_bitrate') or '').split(' ')[0]),
109 'fps': metadata
.get('fps'),
114 'width': f
.get('width'),
115 'height': f
.get('height'),
116 'tbr': int_or_none(f
.get('bitrate'), scale
=1000),
118 } for url
, f
in ((media
.get('url'), metadata
.get('original') or {}),
119 (media
.get('source_mp4'), metadata
.get('playable') or {})) if url
]
121 author
= json_data
.get('account') or {}
123 'id': f
'{post_id}-{idx}',
124 'title': f
'{json_data["account"]["display_name"]} on Gab',
125 'timestamp': unified_timestamp(json_data
.get('created_at')),
127 'description': clean_html(json_data
.get('content')),
128 'duration': metadata
.get('duration') or parse_duration(metadata
.get('length')),
129 'like_count': json_data
.get('favourites_count'),
130 'comment_count': json_data
.get('replies_count'),
131 'repost_count': json_data
.get('reblogs_count'),
132 'uploader': author
.get('username'),
133 'uploader_id': author
.get('id'),
134 'uploader_url': author
.get('url'),
138 return self
.playlist_result(entries
, post_id
)