2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_str
15 class PeerTubeIE(InfoExtractor):
19 # Taken from https://instances.joinpeertube.org/instances
20 tube\.openalgeria\.org|
21 peertube\.pointsecu\.fr|
22 peertube\.nogafa\.org|
24 megatube\.lilomoino\.fr|
25 peertube\.tamanoir\.foucry\.net|
26 peertube\.inapurna\.org|
27 peertube\.netzspielplatz\.de|
28 video\.deadsuperhero\.com|
29 peertube\.devosi\.org|
30 peertube\.1312\.media|
31 tube\.worldofhauru\.xyz|
32 tube\.bootlicker\.party|
34 peertube\.geekshell\.fr|
36 peertube\.peshane\.net|
38 tube\.homecomputing\.fr|
39 videos\.cloudfrancois\.fr|
40 peertube\.viviers-fibre\.net|
45 peertube\.gaialabs\.ch|
46 peertube\.extremely\.online|
47 peertube\.public-infrastructure\.eu|
57 peertube\.geekael\.fr|
59 video\.anormallostpod\.ovh|
62 videos\.iut-orsay\.fr|
63 peertube\.solidev\.net|
64 videos\.symphonie-of-code\.fr|
67 peertube\.gwendalavir\.eu|
68 video\.passageenseine\.fr|
69 videos\.festivalparminous\.org|
70 peertube\.touhoppai\.moe|
71 peertube\.duckdns\.org|
73 peertube\.mastodon\.host|
74 firedragonvideos\.com|
79 peertube\.walkingmountains\.fr|
83 jp\.peertube\.network|
86 peertube\.angristan\.xyz|
87 peertube\.parleur\.net|
96 peertube\.gegeweb\.eu|
99 tube\.conferences-gesticulees\.net|
100 peertube\.datagueule\.tv|
102 meilleurtube\.delire\.party|
103 tube\.mochi\.academy|
107 peertube\.valvin\.fr|
109 video\.colibris-outilslibres\.org|
110 video\.hispagatos\.org|
113 videos\.lecygnenoir\.info|
119 /videos/watch/(?P<id>[^/?#&]+)
122 'url': 'https://peertube.moe/videos/watch/2790feb0-8120-4e63-9af3-c943c69f5e6c',
123 'md5': '80f24ff364cc9d333529506a263e7feb',
125 'id': '2790feb0-8120-4e63-9af3-c943c69f5e6c',
128 'description': 'wow such video, so gif',
129 'thumbnail': r're:https?://.*\.(?:jpg|png)',
130 'timestamp': 1519297480,
131 'upload_date': '20180222',
132 'uploader': 'Luclu7',
133 'uploader_id': '7fc42640-efdb-4505-a45d-a15b1a5496f1',
134 'uploder_url': 'https://peertube.nsa.ovh/accounts/luclu7',
135 'license': 'Unknown',
139 'dislike_count': int,
144 'url': 'https://peertube.tamanoir.foucry.net/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
145 'only_matching': True,
148 'url': 'https://tube.22decembre.eu/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
149 'only_matching': True,
152 def _real_extract(self, url):
153 video_id = self._match_id(url)
155 video = self._download_json(
156 urljoin(url, '/api/v1/videos/%s' % video_id), video_id)
158 title = video['name']
161 for file_ in video['files']:
162 if not isinstance(file_, dict):
164 file_url = file_.get('fileUrl')
165 if not file_url or not isinstance(file_url, compat_str):
167 file_size = int_or_none(file_.get('size'))
169 file_, lambda x: x['resolution']['label'], compat_str)
170 f = parse_resolution(format_id)
173 'format_id': format_id,
174 'filesize': file_size,
177 self._sort_formats(formats)
179 def account_data(field):
180 return try_get(video, lambda x: x['account'][field], compat_str)
182 category = try_get(video, lambda x: x['category']['label'], compat_str)
183 categories = [category] if category else None
185 nsfw = video.get('nsfw')
187 age_limit = 18 if nsfw else 0
194 'description': video.get('description'),
195 'thumbnail': urljoin(url, video.get('thumbnailPath')),
196 'timestamp': unified_timestamp(video.get('publishedAt')),
197 'uploader': account_data('displayName'),
198 'uploader_id': account_data('uuid'),
199 'uploder_url': account_data('url'),
201 video, lambda x: x['licence']['label'], compat_str),
202 'duration': int_or_none(video.get('duration')),
203 'view_count': int_or_none(video.get('views')),
204 'like_count': int_or_none(video.get('likes')),
205 'dislike_count': int_or_none(video.get('dislikes')),
206 'age_limit': age_limit,
207 'tags': try_get(video, lambda x: x['tags'], list),
208 'categories': categories,