]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/peertube.py
d3a83ea2bb5215e34e72ad85bf99867697e2e1b2
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
18 class PeerTubeIE(InfoExtractor
):
19 _INSTANCES_RE
= r
'''(?:
20 # Taken from https://instances.joinpeertube.org/instances
21 peertube\.rainbowswingers\.net|
25 videomensoif\.ynh\.fr|
26 peertube\.travelpandas\.eu|
27 peertube\.rachetjay\.fr|
28 peertube\.montecsys\.fr|
31 peertube\.umeahackerspace\.se|
33 video\.monsieurbidouille\.fr|
34 tube\.openalgeria\.org|
36 video\.anormallostpod\.ovh|
37 tube\.crapaud-fou\.org|
41 peertube\.snargol\.com|
46 peertube\.osureplayviewer\.xyz|
47 peertube\.mathieufamily\.ovh|
50 peertube\.fediverse\.ru|
51 peertube\.oiseauroch\.fr|
59 peertube\.chantierlibre\.org|
65 videos\.elbinario\.net|
71 peertube\.gnumeria\.eu\.org|
75 tube\.kalah-france\.org|
79 peertube\.hatthieves\.es|
80 video\.fitchfamily\.org|
85 peertube\.harmoniescreatives\.com|
88 video\.bruitbruit\.com|
89 peertube\.foxfam\.club|
92 peertube\.malbert\.xyz|
93 peertube\.bilange\.ca|
96 peertube\.fedilab\.app|
98 video\.mstddntfdn\.online|
100 peertube\.sl-network\.fr|
101 peertube\.dynlinux\.io|
102 peertube\.david\.durieux\.family|
103 peertube\.linuxrocks\.online|
105 v\.kretschmann\.social|
108 tube\.dragonpsi\.xyz|
109 peertube\.boneheadmedia\.com|
110 videos\.funkwhale\.audio|
112 peertube\.gcaillaut\.fr|
119 peertube\.simounet\.net|
123 peertube\.kerenon\.com|
125 tube\.calculate\.social|
126 peertube\.mckillop\.org|
127 tube\.netzspielplatz\.de|
131 peertube\.stephenson\.cc|
133 peertube\.kajalinifi\.de|
136 peertube\.ffs2play\.fr|
137 peertube\.leboulaire\.ovh|
138 peertube\.tronic-studio\.com|
139 peertube\.public\.cat|
140 peertube\.metalbanana\.net|
142 peertube\.alter-nativ-voll\.de|
144 tube\.worldofhauru\.xyz|
146 peertube\.teleassist\.fr|
149 media\.privacyinternational\.org|
151 video\.halle-leaks\.de|
152 video\.grosskopfgames\.de|
153 peertube\.schaeferit\.de|
154 peertube\.jackbot\.fr|
155 tube\.extinctionrebellion\.fr|
159 peertube\.zergy\.net|
160 peertube\.roflcopter\.fr|
161 peertube\.floss-marketing-school\.com|
163 peertube\.iriseden\.eu|
164 videos\.ubuntu-paris\.org|
165 peertube\.mastodon\.host|
167 peertube\.s2s\.video|
172 peertube\.normandie-libre\.fr|
174 video\.lacaveatonton\.ovh|
176 peertube\.servebeer\.com|
177 peertube\.fedi\.quebec|
182 tube\.unmondemeilleur\.eu|
189 video\.devinberg\.com|
191 peertube\.kosebamse\.com|
192 yunopeertube\.myddns\.me|
193 peertube\.varney\.fr|
194 peertube\.anon-kenkai\.com|
197 videos\.dinofly\.com|
201 video\.heromuster\.com|
202 video\.lemediatv\.fr|
207 pt\.laurentkruger\.fr|
208 video\.monarch-pass\.net|
209 peertube\.artica\.center|
210 video\.alternanet\.fr|
212 fanvid\.stopthatimp\.net|
217 peertube\.mablr\.org|
221 devtube\.dev-wiki\.de|
222 raptube\.antipub\.org|
224 peertube\.mygaia\.org|
226 peertube\.livingutopia\.org|
227 peertube\.the-penguin\.de|
228 tube\.thechangebook\.org|
232 mplayer\.demouliere\.eu|
235 peertube\.zapashcanon\.fr|
236 video\.latavernedejohnjohn\.fr|
237 peertube\.pcservice46\.fr|
238 peertube\.mazzonetto\.eu|
239 video\.irem\.univ-paris-diderot\.fr|
240 video\.livecchi\.cloud|
243 video\.cabane-libre\.org|
244 peertube\.openstreetmap\.fr|
245 videos\.alolise\.org|
251 peertube\.freeforge\.eu|
252 video\.arbitrarion\.com|
253 video\.datsemultimedia\.com|
255 peertube\.ricostrongxxx\.com|
256 docker\.videos\.lecygnenoir\.info|
257 peertube\.togart\.de|
258 tube\.postblue\.info|
259 videos\.domainepublic\.net|
260 peertube\.cyber-tribal\.com|
261 video\.gresille\.org|
262 peertube\.dsmouse\.net|
263 cinema\.yunohost\.support|
264 tube\.theocevaer\.fr|
268 peertube\.metawurst\.space|
271 video\.freeradical\.zone|
274 pt\.kircheneuenburg\.de|
277 videos\.side-ways\.net|
280 video\.taboulisme\.com|
284 video\.monsieur-a\.fr|
285 peertube\.librelois\.fr|
286 videos\.pair2jeux\.tube|
287 videos\.pueseso\.club|
288 peer\.mathdacloud\.ovh|
289 media\.assassinate-you\.net|
291 ptube\.rousset\.nom\.fr|
295 peertube\.makotoworkshop\.org|
296 peertube\.serveur\.slv-valbonne\.fr|
301 pire\.artisanlogiciel\.net|
302 videos\.numerique-en-commun\.fr|
304 video\.die-partei\.social|
306 peertube\.swarm\.solvingmaz\.es|
307 tube\.pericoloso\.ovh|
308 watching\.cypherpunk\.observer|
309 videos\.adhocmusic\.com|
311 peertube\.librelabucm\.org|
312 videos\.numericoop\.fr|
313 peertube\.koehn\.com|
314 peertube\.anarchmusicall\.net|
315 tube\.kampftoast\.de|
317 peertube\.xtenz\.xyz|
320 peertube\.nomagic\.uk|
322 videos\.koumoul\.com|
323 video\.rastapuls\.com|
324 video\.mantlepro\.com|
325 video\.deadsuperhero\.com|
326 peertube\.musicstudio\.pro|
327 peertube\.we-keys\.fr|
328 artitube\.artifaille\.fr|
329 peertube\.ethernia\.net|
333 peertube\.donnadieu\.fr|
334 argos\.aquilenet\.fr|
337 videos\.darckoune\.moe|
338 tube\.traydent\.info|
339 dev\.videos\.lecygnenoir\.info|
340 peertube\.nayya\.org|
342 peertube\.mofgao\.space|
343 video\.lequerrec\.eu|
344 peertube\.amicale\.net|
353 peertube\.heberge\.fr|
355 videos\.cloudfrancois\.fr|
364 videos\.lescommuns\.org|
368 peertube\.nogafa\.org|
369 megatube\.lilomoino\.fr|
370 peertube\.tamanoir\.foucry\.net|
371 peertube\.devosi\.org|
372 peertube\.1312\.media|
373 tube\.bootlicker\.party|
376 tube\.homecomputing\.fr|
377 tube\.ouahpiti\.info|
381 peertube\.gaialabs\.ch|
384 video\.migennes\.net|
387 videos\.iut-orsay\.fr|
388 peertube\.solidev\.net|
390 video\.passageenseine\.fr|
391 videos\.festivalparminous\.org|
392 peertube\.touhoppai\.moe|
394 peer\.hostux\.social|
396 peertube\.walkingmountains\.fr|
398 peertube\.parleur\.net|
399 peertube\.heraut\.eu|
401 peertube\.gegeweb\.eu|
404 tube\.conferences-gesticulees\.net|
405 peertube\.datagueule\.tv|
407 tube\.mochi\.academy|
409 video\.colibris-outilslibres\.org|
417 _UUID_RE
= r
'[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}'
418 _VALID_URL
= r
'''(?x)
420 peertube:(?P<host>[^:]+):|
421 https?://(?P<host_2>%s)/(?:videos/(?:watch|embed)|api/v\d/videos)/
424 ''' % (_INSTANCES_RE
, _UUID_RE
)
426 'url': 'https://peertube.cpy.re/videos/watch/2790feb0-8120-4e63-9af3-c943c69f5e6c',
427 'md5': '80f24ff364cc9d333529506a263e7feb',
429 'id': '2790feb0-8120-4e63-9af3-c943c69f5e6c',
432 'description': 'wow such video, so gif',
433 'thumbnail': r
're:https?://.*\.(?:jpg|png)',
434 'timestamp': 1519297480,
435 'upload_date': '20180222',
436 'uploader': 'Luclu7',
437 'uploader_id': '7fc42640-efdb-4505-a45d-a15b1a5496f1',
438 'uploder_url': 'https://peertube.nsa.ovh/accounts/luclu7',
439 'license': 'Unknown',
443 'dislike_count': int,
448 'url': 'https://peertube.tamanoir.foucry.net/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
449 'only_matching': True,
452 'url': 'https://tube.22decembre.eu/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
453 'only_matching': True,
455 'url': 'https://tube.22decembre.eu/videos/embed/fed67262-6edb-4d1c-833b-daa9085c71d7',
456 'only_matching': True,
458 'url': 'https://tube.openalgeria.org/api/v1/videos/c1875674-97d0-4c94-a058-3f7e64c962e8',
459 'only_matching': True,
461 'url': 'peertube:video.blender.org:b37a5b9f-e6b5-415c-b700-04a5cd6ec205',
462 'only_matching': True,
466 def _extract_peertube_url(webpage
, source_url
):
468 r
'https?://(?P<host>[^/]+)/videos/(?:watch|embed)/(?P<id>%s)'
469 % PeerTubeIE
._UUID
_RE
, source_url
)
470 if mobj
and any(p
in webpage
for p
in (
472 'There will be other non JS-based clients to access PeerTube',
473 '>We are sorry but it seems that PeerTube is not compatible with your web browser.<')):
474 return 'peertube:%s:%s' % mobj
.group('host', 'id')
477 def _extract_urls(webpage
, source_url
):
478 entries
= re
.findall(
479 r
'''(?x)<iframe[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//%s/videos
/embed
/%s)'''
480 % (PeerTubeIE._INSTANCES_RE, PeerTubeIE._UUID_RE), webpage)
482 peertube_url = PeerTubeIE._extract_peertube_url(webpage, source_url)
484 entries = [peertube_url]
487 def _real_extract(self, url):
488 mobj = re.match(self._VALID_URL, url)
489 host = mobj.group('host') or mobj.group('host_2')
490 video_id = mobj.group('id')
492 video = self._download_json(
493 'https://%s/api/v1/videos/%s' % (host, video_id), video_id)
495 title = video['name']
498 for file_ in video['files']:
499 if not isinstance(file_, dict):
501 file_url = url_or_none(file_.get('fileUrl'))
504 file_size = int_or_none(file_.get('size'))
506 file_, lambda x: x['resolution']['label'], compat_str)
507 f = parse_resolution(format_id)
510 'format_id': format_id,
511 'filesize': file_size,
514 self._sort_formats(formats)
516 def account_data(field):
517 return try_get(video, lambda x: x['account'][field], compat_str)
519 category = try_get(video, lambda x: x['category']['label'], compat_str)
520 categories = [category] if category else None
522 nsfw = video.get('nsfw')
524 age_limit = 18 if nsfw else 0
531 'description': video.get('description'),
532 'thumbnail': urljoin(url, video.get('thumbnailPath')),
533 'timestamp': unified_timestamp(video.get('publishedAt')),
534 'uploader': account_data('displayName'),
535 'uploader_id': account_data('uuid'),
536 'uploder_url': account_data('url'),
538 video, lambda x: x['licence']['label'], compat_str),
539 'duration': int_or_none(video.get('duration')),
540 'view_count': int_or_none(video.get('views')),
541 'like_count': int_or_none(video.get('likes')),
542 'dislike_count': int_or_none(video.get('dislikes')),
543 'age_limit': age_limit,
544 'tags': try_get(video, lambda x: x['tags'], list),
545 'categories': categories,