]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/peertube.py
[go,viu] Extract subtitles from the m3u8 manifest (#3219)
[yt-dlp.git] / yt_dlp / extractor / peertube.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import functools
5 import re
6
7 from .common import InfoExtractor
8 from ..compat import compat_str
9 from ..utils import (
10 format_field,
11 int_or_none,
12 parse_resolution,
13 str_or_none,
14 try_get,
15 unified_timestamp,
16 url_or_none,
17 urljoin,
18 OnDemandPagedList,
19 )
20
21
22 class PeerTubeIE(InfoExtractor):
23 _INSTANCES_RE = r'''(?:
24 # Taken from https://instances.joinpeertube.org/instances
25 40two\.tube|
26 a\.metube\.ch|
27 advtv\.ml|
28 algorithmic\.tv|
29 alimulama\.com|
30 arcana\.fun|
31 archive\.vidicon\.org|
32 artefac-paris\.tv|
33 auf1\.eu|
34 battlepenguin\.video|
35 beertube\.epgn\.ch|
36 befree\.nohost\.me|
37 bideoak\.argia\.eus|
38 birkeundnymphe\.de|
39 bitcointv\.com|
40 cattube\.org|
41 clap\.nerv-project\.eu|
42 climatejustice\.video|
43 comf\.tube|
44 conspiracydistillery\.com|
45 darkvapor\.nohost\.me|
46 daschauher\.aksel\.rocks|
47 digitalcourage\.video|
48 dreiecksnebel\.alex-detsch\.de|
49 eduvid\.org|
50 evangelisch\.video|
51 exo\.tube|
52 fair\.tube|
53 fediverse\.tv|
54 film\.k-prod\.fr|
55 flim\.txmn\.tk|
56 fotogramas\.politicaconciencia\.org|
57 ftsi\.ru|
58 gary\.vger\.cloud|
59 graeber\.video|
60 greatview\.video|
61 grypstube\.uni-greifswald\.de|
62 highvoltage\.tv|
63 hpstube\.fr|
64 htp\.live|
65 hyperreal\.tube|
66 juggling\.digital|
67 kino\.kompot\.si|
68 kino\.schuerz\.at|
69 kinowolnosc\.pl|
70 kirche\.peertube-host\.de|
71 kodcast\.com|
72 kolektiva\.media|
73 kraut\.zone|
74 kumi\.tube|
75 lastbreach\.tv|
76 lepetitmayennais\.fr\.nf|
77 lexx\.impa\.me|
78 libertynode\.tv|
79 libra\.syntazia\.org|
80 libremedia\.video|
81 live\.libratoi\.org|
82 live\.nanao\.moe|
83 live\.toobnix\.org|
84 livegram\.net|
85 lolitube\.freedomchan\.moe|
86 lucarne\.balsamine\.be|
87 maindreieck-tv\.de|
88 mani\.tube|
89 manicphase\.me|
90 media\.fsfe\.org|
91 media\.gzevd\.de|
92 media\.inno3\.cricket|
93 media\.kaitaia\.life|
94 media\.krashboyz\.org|
95 media\.over-world\.org|
96 media\.skewed\.de|
97 media\.undeadnetwork\.de|
98 medias\.pingbase\.net|
99 melsungen\.peertube-host\.de|
100 mirametube\.fr|
101 mojotube\.net|
102 monplaisirtube\.ddns\.net|
103 mountaintown\.video|
104 my\.bunny\.cafe|
105 myfreetube\.de|
106 mytube\.kn-cloud\.de|
107 mytube\.madzel\.de|
108 myworkoutarenapeertube\.cf|
109 nanawel-peertube\.dyndns\.org|
110 nastub\.cz|
111 offenes\.tv|
112 orgdup\.media|
113 ovaltube\.codinglab\.ch|
114 p2ptv\.ru|
115 p\.eertu\.be|
116 p\.lu|
117 peer\.azurs\.fr|
118 peertube1\.zeteo\.me|
119 peertube\.020\.pl|
120 peertube\.0x5e\.eu|
121 peertube\.alpharius\.io|
122 peertube\.am-networks\.fr|
123 peertube\.anduin\.net|
124 peertube\.anzui\.dev|
125 peertube\.arbleizez\.bzh|
126 peertube\.art3mis\.de|
127 peertube\.atilla\.org|
128 peertube\.atsuchan\.page|
129 peertube\.aukfood\.net|
130 peertube\.aventer\.biz|
131 peertube\.b38\.rural-it\.org|
132 peertube\.beeldengeluid\.nl|
133 peertube\.be|
134 peertube\.bgzashtita\.es|
135 peertube\.bitsandlinux\.com|
136 peertube\.biz|
137 peertube\.boba\.best|
138 peertube\.br0\.fr|
139 peertube\.bridaahost\.ynh\.fr|
140 peertube\.bubbletea\.dev|
141 peertube\.bubuit\.net|
142 peertube\.cabaal\.net|
143 peertube\.cats-home\.net|
144 peertube\.chemnitz\.freifunk\.net|
145 peertube\.chevro\.fr|
146 peertube\.chrisspiegl\.com|
147 peertube\.chtisurel\.net|
148 peertube\.cipherbliss\.com|
149 peertube\.cloud\.sans\.pub|
150 peertube\.cpge-brizeux\.fr|
151 peertube\.ctseuro\.com|
152 peertube\.cuatrolibertades\.org|
153 peertube\.cybercirujas\.club|
154 peertube\.cythin\.com|
155 peertube\.davigge\.com|
156 peertube\.dc\.pini\.fr|
157 peertube\.debian\.social|
158 peertube\.demonix\.fr|
159 peertube\.designersethiques\.org|
160 peertube\.desmu\.fr|
161 peertube\.devloprog\.org|
162 peertube\.devol\.it|
163 peertube\.dtmf\.ca|
164 peertube\.ecologie\.bzh|
165 peertube\.eu\.org|
166 peertube\.european-pirates\.eu|
167 peertube\.euskarabildua\.eus|
168 peertube\.fenarinarsa\.com|
169 peertube\.fomin\.site|
170 peertube\.forsud\.be|
171 peertube\.francoispelletier\.org|
172 peertube\.freenet\.ru|
173 peertube\.freetalklive\.com|
174 peertube\.functional\.cafe|
175 peertube\.gardeludwig\.fr|
176 peertube\.gargantia\.fr|
177 peertube\.gcfamily\.fr|
178 peertube\.genma\.fr|
179 peertube\.get-racing\.de|
180 peertube\.gidikroon\.eu|
181 peertube\.gruezishop\.ch|
182 peertube\.habets\.house|
183 peertube\.hackerfraternity\.org|
184 peertube\.ichigo\.everydayimshuflin\.com|
185 peertube\.ignifi\.me|
186 peertube\.inapurna\.org|
187 peertube\.informaction\.info|
188 peertube\.interhop\.org|
189 peertube\.iselfhost\.com|
190 peertube\.it|
191 peertube\.jensdiemer\.de|
192 peertube\.joffreyverd\.fr|
193 peertube\.kalua\.im|
194 peertube\.kathryl\.fr|
195 peertube\.keazilla\.net|
196 peertube\.klaewyss\.fr|
197 peertube\.kodcast\.com|
198 peertube\.kx\.studio|
199 peertube\.lagvoid\.com|
200 peertube\.lavallee\.tech|
201 peertube\.le5emeaxe\.fr|
202 peertube\.lestutosdeprocessus\.fr|
203 peertube\.librenet\.co\.za|
204 peertube\.logilab\.fr|
205 peertube\.louisematic\.site|
206 peertube\.luckow\.org|
207 peertube\.luga\.at|
208 peertube\.lyceeconnecte\.fr|
209 peertube\.manalejandro\.com|
210 peertube\.marud\.fr|
211 peertube\.mattone\.net|
212 peertube\.maxweiss\.io|
213 peertube\.monlycee\.net|
214 peertube\.mxinfo\.fr|
215 peertube\.myrasp\.eu|
216 peertube\.nebelcloud\.de|
217 peertube\.netzbegruenung\.de|
218 peertube\.newsocial\.tech|
219 peertube\.nicolastissot\.fr|
220 peertube\.nz|
221 peertube\.offerman\.com|
222 peertube\.opencloud\.lu|
223 peertube\.orthus\.link|
224 peertube\.patapouf\.xyz|
225 peertube\.pi2\.dev|
226 peertube\.plataformess\.org|
227 peertube\.pl|
228 peertube\.portaesgnos\.org|
229 peertube\.r2\.enst\.fr|
230 peertube\.r5c3\.fr|
231 peertube\.radres\.xyz|
232 peertube\.red|
233 peertube\.robonomics\.network|
234 peertube\.rtnkv\.cloud|
235 peertube\.runfox\.tk|
236 peertube\.satoshishop\.de|
237 peertube\.scic-tetris\.org|
238 peertube\.securitymadein\.lu|
239 peertube\.semweb\.pro|
240 peertube\.social\.my-wan\.de|
241 peertube\.soykaf\.org|
242 peertube\.stefofficiel\.me|
243 peertube\.stream|
244 peertube\.su|
245 peertube\.swrs\.net|
246 peertube\.takeko\.cyou|
247 peertube\.tangentfox\.com|
248 peertube\.taxinachtegel\.de|
249 peertube\.thenewoil\.xyz|
250 peertube\.ti-fr\.com|
251 peertube\.tiennot\.net|
252 peertube\.troback\.com|
253 peertube\.tspu\.edu\.ru|
254 peertube\.tux\.ovh|
255 peertube\.tv|
256 peertube\.tweb\.tv|
257 peertube\.ucy\.de|
258 peertube\.underworld\.fr|
259 peertube\.us\.to|
260 peertube\.ventresmous\.fr|
261 peertube\.vlaki\.cz|
262 peertube\.w\.utnw\.de|
263 peertube\.westring\.digital|
264 peertube\.xwiki\.com|
265 peertube\.zoz-serv\.org|
266 peervideo\.ru|
267 periscope\.numenaute\.org|
268 perron-tube\.de|
269 petitlutinartube\.fr|
270 phijkchu\.com|
271 pierre\.tube|
272 piraten\.space|
273 play\.rosano\.ca|
274 player\.ojamajo\.moe|
275 plextube\.nl|
276 pocketnetpeertube1\.nohost\.me|
277 pocketnetpeertube3\.nohost\.me|
278 pocketnetpeertube4\.nohost\.me|
279 pocketnetpeertube5\.nohost\.me|
280 pocketnetpeertube6\.nohost\.me|
281 pt\.24-7\.ro|
282 pt\.apathy\.top|
283 pt\.diaspodon\.fr|
284 pt\.fedi\.tech|
285 pt\.maciej\.website|
286 ptb\.lunarviews\.net|
287 ptmir1\.inter21\.net|
288 ptmir2\.inter21\.net|
289 ptmir3\.inter21\.net|
290 ptmir4\.inter21\.net|
291 ptmir5\.inter21\.net|
292 ptube\.horsentiers\.fr|
293 ptube\.xmanifesto\.club|
294 queermotion\.org|
295 re-wizja\.re-medium\.com|
296 regarder\.sans\.pub|
297 ruraletv\.ovh|
298 s1\.gegenstimme\.tv|
299 s2\.veezee\.tube|
300 sdmtube\.fr|
301 sender-fm\.veezee\.tube|
302 serv1\.wiki-tube\.de|
303 serv3\.wiki-tube\.de|
304 sickstream\.net|
305 sleepy\.tube|
306 sovran\.video|
307 spectra\.video|
308 stream\.elven\.pw|
309 stream\.k-prod\.fr|
310 stream\.shahab\.nohost\.me|
311 streamsource\.video|
312 studios\.racer159\.com|
313 testtube\.florimond\.eu|
314 tgi\.hosted\.spacebear\.ee|
315 thaitube\.in\.th|
316 the\.jokertv\.eu|
317 theater\.ethernia\.net|
318 thecool\.tube|
319 tilvids\.com|
320 toob\.bub\.org|
321 tpaw\.video|
322 truetube\.media|
323 tuba\.lhub\.pl|
324 tube-aix-marseille\.beta\.education\.fr|
325 tube-amiens\.beta\.education\.fr|
326 tube-besancon\.beta\.education\.fr|
327 tube-bordeaux\.beta\.education\.fr|
328 tube-clermont-ferrand\.beta\.education\.fr|
329 tube-corse\.beta\.education\.fr|
330 tube-creteil\.beta\.education\.fr|
331 tube-dijon\.beta\.education\.fr|
332 tube-education\.beta\.education\.fr|
333 tube-grenoble\.beta\.education\.fr|
334 tube-lille\.beta\.education\.fr|
335 tube-limoges\.beta\.education\.fr|
336 tube-montpellier\.beta\.education\.fr|
337 tube-nancy\.beta\.education\.fr|
338 tube-nantes\.beta\.education\.fr|
339 tube-nice\.beta\.education\.fr|
340 tube-normandie\.beta\.education\.fr|
341 tube-orleans-tours\.beta\.education\.fr|
342 tube-outremer\.beta\.education\.fr|
343 tube-paris\.beta\.education\.fr|
344 tube-poitiers\.beta\.education\.fr|
345 tube-reims\.beta\.education\.fr|
346 tube-rennes\.beta\.education\.fr|
347 tube-strasbourg\.beta\.education\.fr|
348 tube-toulouse\.beta\.education\.fr|
349 tube-versailles\.beta\.education\.fr|
350 tube1\.it\.tuwien\.ac\.at|
351 tube\.abolivier\.bzh|
352 tube\.ac-amiens\.fr|
353 tube\.aerztefueraufklaerung\.de|
354 tube\.alexx\.ml|
355 tube\.amic37\.fr|
356 tube\.anufrij\.de|
357 tube\.apolut\.net|
358 tube\.arkhalabs\.io|
359 tube\.arthack\.nz|
360 tube\.as211696\.net|
361 tube\.avensio\.de|
362 tube\.azbyka\.ru|
363 tube\.azkware\.net|
364 tube\.bachaner\.fr|
365 tube\.bmesh\.org|
366 tube\.borked\.host|
367 tube\.bstly\.de|
368 tube\.chaoszone\.tv|
369 tube\.chatelet\.ovh|
370 tube\.cloud-libre\.eu|
371 tube\.cms\.garden|
372 tube\.cowfee\.moe|
373 tube\.cryptography\.dog|
374 tube\.darknight-coffee\.org|
375 tube\.dev\.lhub\.pl|
376 tube\.distrilab\.fr|
377 tube\.dsocialize\.net|
378 tube\.ebin\.club|
379 tube\.fdn\.fr|
380 tube\.florimond\.eu|
381 tube\.foxarmy\.ml|
382 tube\.foxden\.party|
383 tube\.frischesicht\.de|
384 tube\.futuretic\.fr|
385 tube\.gnous\.eu|
386 tube\.grap\.coop|
387 tube\.graz\.social|
388 tube\.grin\.hu|
389 tube\.hackerscop\.org|
390 tube\.hordearii\.fr|
391 tube\.jeena\.net|
392 tube\.kai-stuht\.com|
393 tube\.kockatoo\.org|
394 tube\.kotur\.org|
395 tube\.lacaveatonton\.ovh|
396 tube\.linkse\.media|
397 tube\.lokad\.com|
398 tube\.lucie-philou\.com|
399 tube\.melonbread\.xyz|
400 tube\.mfraters\.net|
401 tube\.motuhake\.xyz|
402 tube\.mrbesen\.de|
403 tube\.nah\.re|
404 tube\.nchoco\.net|
405 tube\.novg\.net|
406 tube\.nox-rhea\.org|
407 tube\.nuagelibre\.fr|
408 tube\.nx12\.net|
409 tube\.octaplex\.net|
410 tube\.odat\.xyz|
411 tube\.oisux\.org|
412 tube\.opportunis\.me|
413 tube\.org\.il|
414 tube\.ortion\.xyz|
415 tube\.others\.social|
416 tube\.picasoft\.net|
417 tube\.plomlompom\.com|
418 tube\.pmj\.rocks|
419 tube\.portes-imaginaire\.org|
420 tube\.pyngu\.com|
421 tube\.rebellion\.global|
422 tube\.rhythms-of-resistance\.org|
423 tube\.rita\.moe|
424 tube\.rsi\.cnr\.it|
425 tube\.s1gm4\.eu|
426 tube\.saumon\.io|
427 tube\.schleuss\.online|
428 tube\.schule\.social|
429 tube\.seditio\.fr|
430 tube\.shanti\.cafe|
431 tube\.shela\.nu|
432 tube\.skrep\.in|
433 tube\.sp-codes\.de|
434 tube\.sp4ke\.com|
435 tube\.superseriousbusiness\.org|
436 tube\.systest\.eu|
437 tube\.tappret\.fr|
438 tube\.tardis\.world|
439 tube\.toontoet\.nl|
440 tube\.tpshd\.de|
441 tube\.troopers\.agency|
442 tube\.tylerdavis\.xyz|
443 tube\.undernet\.uy|
444 tube\.vigilian-consulting\.nl|
445 tube\.vraphim\.com|
446 tube\.wehost\.lgbt|
447 tube\.wien\.rocks|
448 tube\.wolfe\.casa|
449 tube\.xd0\.de|
450 tube\.xy-space\.de|
451 tube\.yapbreak\.fr|
452 tubedu\.org|
453 tubes\.jodh\.us|
454 tuktube\.com|
455 turkum\.me|
456 tututu\.tube|
457 tuvideo\.encanarias\.info|
458 tv1\.cocu\.cc|
459 tv1\.gomntu\.space|
460 tv2\.cocu\.cc|
461 tv\.adn\.life|
462 tv\.atmx\.ca|
463 tv\.bitma\.st|
464 tv\.generallyrubbish\.net\.au|
465 tv\.lumbung\.space|
466 tv\.mattchristiansenmedia\.com|
467 tv\.netwhood\.online|
468 tv\.neue\.city|
469 tv\.piejacker\.net|
470 tv\.pirateradio\.social|
471 tv\.undersco\.re|
472 tvox\.ru|
473 twctube\.twc-zone\.eu|
474 unfilter\.tube|
475 v\.basspistol\.org|
476 v\.kisombrella\.top|
477 v\.lastorder\.xyz|
478 v\.lor\.sh|
479 v\.phreedom\.club|
480 v\.sil\.sh|
481 v\.szy\.io|
482 v\.xxxapex\.com|
483 veezee\.tube|
484 vid\.dascoyote\.xyz|
485 vid\.garwood\.io|
486 vid\.ncrypt\.at|
487 vid\.pravdastalina\.info|
488 vid\.qorg11\.net|
489 vid\.rajeshtaylor\.com|
490 vid\.samtripoli\.com|
491 vid\.werefox\.dev|
492 vid\.wildeboer\.net|
493 video-cave-v2\.de|
494 video\.076\.ne\.jp|
495 video\.1146\.nohost\.me|
496 video\.altertek\.org|
497 video\.anartist\.org|
498 video\.apps\.thedoodleproject\.net|
499 video\.artist\.cx|
500 video\.asgardius\.company|
501 video\.balsillie\.net|
502 video\.bards\.online|
503 video\.binarydad\.com|
504 video\.blast-info\.fr|
505 video\.catgirl\.biz|
506 video\.cigliola\.com|
507 video\.cm-en-transition\.fr|
508 video\.cnt\.social|
509 video\.coales\.co|
510 video\.codingfield\.com|
511 video\.comptoir\.net|
512 video\.comune\.trento\.it|
513 video\.cpn\.so|
514 video\.csc49\.fr|
515 video\.cybre\.town|
516 video\.demokratischer-sommer\.de|
517 video\.discord-insoumis\.fr|
518 video\.dolphincastle\.com|
519 video\.dresden\.network|
520 video\.ecole-89\.com|
521 video\.elgrillolibertario\.org|
522 video\.emergeheart\.info|
523 video\.eradicatinglove\.xyz|
524 video\.ethantheenigma\.me|
525 video\.exodus-privacy\.eu\.org|
526 video\.fbxl\.net|
527 video\.fhtagn\.org|
528 video\.greenmycity\.eu|
529 video\.guerredeclasse\.fr|
530 video\.gyt\.is|
531 video\.hackers\.town|
532 video\.hardlimit\.com|
533 video\.hooli\.co|
534 video\.igem\.org|
535 video\.internet-czas-dzialac\.pl|
536 video\.islameye\.com|
537 video\.kicik\.fr|
538 video\.kuba-orlik\.name|
539 video\.kyushojitsu\.ca|
540 video\.lavolte\.net|
541 video\.lespoesiesdheloise\.fr|
542 video\.liberta\.vip|
543 video\.liege\.bike|
544 video\.linc\.systems|
545 video\.linux\.it|
546 video\.linuxtrent\.it|
547 video\.lokal\.social|
548 video\.lono\.space|
549 video\.lunasqu\.ee|
550 video\.lundi\.am|
551 video\.marcorennmaus\.de|
552 video\.mass-trespass\.uk|
553 video\.mugoreve\.fr|
554 video\.mundodesconocido\.com|
555 video\.mycrowd\.ca|
556 video\.nogafam\.es|
557 video\.odayacres\.farm|
558 video\.ozgurkon\.org|
559 video\.p1ng0ut\.social|
560 video\.p3x\.de|
561 video\.pcf\.fr|
562 video\.pony\.gallery|
563 video\.potate\.space|
564 video\.pourpenser\.pro|
565 video\.progressiv\.dev|
566 video\.resolutions\.it|
567 video\.rw501\.de|
568 video\.screamer\.wiki|
569 video\.sdm-tools\.net|
570 video\.sftblw\.moe|
571 video\.shitposter\.club|
572 video\.skyn3t\.in|
573 video\.soi\.ch|
574 video\.stuartbrand\.co\.uk|
575 video\.thinkof\.name|
576 video\.toot\.pt|
577 video\.triplea\.fr|
578 video\.turbo\.chat|
579 video\.vaku\.org\.ua|
580 video\.veloma\.org|
581 video\.violoncello\.ch|
582 video\.wilkie\.how|
583 video\.wsf2021\.info|
584 videorelay\.co|
585 videos-passages\.huma-num\.fr|
586 videos\.3d-wolf\.com|
587 videos\.ahp-numerique\.fr|
588 videos\.alexandrebadalo\.pt|
589 videos\.archigny\.net|
590 videos\.benjaminbrady\.ie|
591 videos\.buceoluegoexisto\.com|
592 videos\.capas\.se|
593 videos\.casually\.cat|
594 videos\.cloudron\.io|
595 videos\.coletivos\.org|
596 videos\.danksquad\.org|
597 videos\.denshi\.live|
598 videos\.fromouter\.space|
599 videos\.fsci\.in|
600 videos\.globenet\.org|
601 videos\.hauspie\.fr|
602 videos\.hush\.is|
603 videos\.john-livingston\.fr|
604 videos\.jordanwarne\.xyz|
605 videos\.lavoixdessansvoix\.org|
606 videos\.leslionsfloorball\.fr|
607 videos\.lucero\.top|
608 videos\.martyn\.berlin|
609 videos\.mastodont\.cat|
610 videos\.monstro1\.com|
611 videos\.npo\.city|
612 videos\.optoutpod\.com|
613 videos\.petch\.rocks|
614 videos\.pzelawski\.xyz|
615 videos\.rampin\.org|
616 videos\.scanlines\.xyz|
617 videos\.shmalls\.pw|
618 videos\.sibear\.fr|
619 videos\.stadtfabrikanten\.org|
620 videos\.tankernn\.eu|
621 videos\.testimonia\.org|
622 videos\.thisishowidontdisappear\.com|
623 videos\.traumaheilung\.net|
624 videos\.trom\.tf|
625 videos\.wakkerewereld\.nu|
626 videos\.weblib\.re|
627 videos\.yesil\.club|
628 vids\.roshless\.me|
629 vids\.tekdmn\.me|
630 vidz\.dou\.bet|
631 vod\.lumikko\.dev|
632 vs\.uniter\.network|
633 vulgarisation-informatique\.fr|
634 watch\.breadtube\.tv|
635 watch\.deranalyst\.ch|
636 watch\.ignorance\.eu|
637 watch\.krazy\.party|
638 watch\.libertaria\.space|
639 watch\.rt4mn\.org|
640 watch\.softinio\.com|
641 watch\.tubelab\.video|
642 web-fellow\.de|
643 webtv\.vandoeuvre\.net|
644 wechill\.space|
645 wikileaks\.video|
646 wiwi\.video|
647 worldofvids\.com|
648 wwtube\.net|
649 www4\.mir\.inter21\.net|
650 www\.birkeundnymphe\.de|
651 www\.captain-german\.com|
652 www\.wiki-tube\.de|
653 xxivproduction\.video|
654 xxx\.noho\.st|
655
656 # from youtube-dl
657 peertube\.rainbowswingers\.net|
658 tube\.stanisic\.nl|
659 peer\.suiri\.us|
660 medias\.libox\.fr|
661 videomensoif\.ynh\.fr|
662 peertube\.travelpandas\.eu|
663 peertube\.rachetjay\.fr|
664 peertube\.montecsys\.fr|
665 tube\.eskuero\.me|
666 peer\.tube|
667 peertube\.umeahackerspace\.se|
668 tube\.nx-pod\.de|
669 video\.monsieurbidouille\.fr|
670 tube\.openalgeria\.org|
671 vid\.lelux\.fi|
672 video\.anormallostpod\.ovh|
673 tube\.crapaud-fou\.org|
674 peertube\.stemy\.me|
675 lostpod\.space|
676 exode\.me|
677 peertube\.snargol\.com|
678 vis\.ion\.ovh|
679 videosdulib\.re|
680 v\.mbius\.io|
681 videos\.judrey\.eu|
682 peertube\.osureplayviewer\.xyz|
683 peertube\.mathieufamily\.ovh|
684 www\.videos-libr\.es|
685 fightforinfo\.com|
686 peertube\.fediverse\.ru|
687 peertube\.oiseauroch\.fr|
688 video\.nesven\.eu|
689 v\.bearvideo\.win|
690 video\.qoto\.org|
691 justporn\.cc|
692 video\.vny\.fr|
693 peervideo\.club|
694 tube\.taker\.fr|
695 peertube\.chantierlibre\.org|
696 tube\.ipfixe\.info|
697 tube\.kicou\.info|
698 tube\.dodsorf\.as|
699 videobit\.cc|
700 video\.yukari\.moe|
701 videos\.elbinario\.net|
702 hkvideo\.live|
703 pt\.tux\.tf|
704 www\.hkvideo\.live|
705 FIGHTFORINFO\.com|
706 pt\.765racing\.com|
707 peertube\.gnumeria\.eu\.org|
708 nordenmedia\.com|
709 peertube\.co\.uk|
710 tube\.darfweb\.eu|
711 tube\.kalah-france\.org|
712 0ch\.in|
713 vod\.mochi\.academy|
714 film\.node9\.org|
715 peertube\.hatthieves\.es|
716 video\.fitchfamily\.org|
717 peertube\.ddns\.net|
718 video\.ifuncle\.kr|
719 video\.fdlibre\.eu|
720 tube\.22decembre\.eu|
721 peertube\.harmoniescreatives\.com|
722 tube\.fabrigli\.fr|
723 video\.thedwyers\.co|
724 video\.bruitbruit\.com|
725 peertube\.foxfam\.club|
726 peer\.philoxweb\.be|
727 videos\.bugs\.social|
728 peertube\.malbert\.xyz|
729 peertube\.bilange\.ca|
730 libretube\.net|
731 diytelevision\.com|
732 peertube\.fedilab\.app|
733 libre\.video|
734 video\.mstddntfdn\.online|
735 us\.tv|
736 peertube\.sl-network\.fr|
737 peertube\.dynlinux\.io|
738 peertube\.david\.durieux\.family|
739 peertube\.linuxrocks\.online|
740 peerwatch\.xyz|
741 v\.kretschmann\.social|
742 tube\.otter\.sh|
743 yt\.is\.nota\.live|
744 tube\.dragonpsi\.xyz|
745 peertube\.boneheadmedia\.com|
746 videos\.funkwhale\.audio|
747 watch\.44con\.com|
748 peertube\.gcaillaut\.fr|
749 peertube\.icu|
750 pony\.tube|
751 spacepub\.space|
752 tube\.stbr\.io|
753 v\.mom-gay\.faith|
754 tube\.port0\.xyz|
755 peertube\.simounet\.net|
756 play\.jergefelt\.se|
757 peertube\.zeteo\.me|
758 tube\.danq\.me|
759 peertube\.kerenon\.com|
760 tube\.fab-l3\.org|
761 tube\.calculate\.social|
762 peertube\.mckillop\.org|
763 tube\.netzspielplatz\.de|
764 vod\.ksite\.de|
765 peertube\.laas\.fr|
766 tube\.govital\.net|
767 peertube\.stephenson\.cc|
768 bistule\.nohost\.me|
769 peertube\.kajalinifi\.de|
770 video\.ploud\.jp|
771 video\.omniatv\.com|
772 peertube\.ffs2play\.fr|
773 peertube\.leboulaire\.ovh|
774 peertube\.tronic-studio\.com|
775 peertube\.public\.cat|
776 peertube\.metalbanana\.net|
777 video\.1000i100\.fr|
778 peertube\.alter-nativ-voll\.de|
779 tube\.pasa\.tf|
780 tube\.worldofhauru\.xyz|
781 pt\.kamp\.site|
782 peertube\.teleassist\.fr|
783 videos\.mleduc\.xyz|
784 conf\.tube|
785 media\.privacyinternational\.org|
786 pt\.forty-two\.nl|
787 video\.halle-leaks\.de|
788 video\.grosskopfgames\.de|
789 peertube\.schaeferit\.de|
790 peertube\.jackbot\.fr|
791 tube\.extinctionrebellion\.fr|
792 peertube\.f-si\.org|
793 video\.subak\.ovh|
794 videos\.koweb\.fr|
795 peertube\.zergy\.net|
796 peertube\.roflcopter\.fr|
797 peertube\.floss-marketing-school\.com|
798 vloggers\.social|
799 peertube\.iriseden\.eu|
800 videos\.ubuntu-paris\.org|
801 peertube\.mastodon\.host|
802 armstube\.com|
803 peertube\.s2s\.video|
804 peertube\.lol|
805 tube\.open-plug\.eu|
806 open\.tube|
807 peertube\.ch|
808 peertube\.normandie-libre\.fr|
809 peertube\.slat\.org|
810 video\.lacaveatonton\.ovh|
811 peertube\.uno|
812 peertube\.servebeer\.com|
813 peertube\.fedi\.quebec|
814 tube\.h3z\.jp|
815 tube\.plus200\.com|
816 peertube\.eric\.ovh|
817 tube\.metadocs\.cc|
818 tube\.unmondemeilleur\.eu|
819 gouttedeau\.space|
820 video\.antirep\.net|
821 nrop\.cant\.at|
822 tube\.ksl-bmx\.de|
823 tube\.plaf\.fr|
824 tube\.tchncs\.de|
825 video\.devinberg\.com|
826 hitchtube\.fr|
827 peertube\.kosebamse\.com|
828 yunopeertube\.myddns\.me|
829 peertube\.varney\.fr|
830 peertube\.anon-kenkai\.com|
831 tube\.maiti\.info|
832 tubee\.fr|
833 videos\.dinofly\.com|
834 toobnix\.org|
835 videotape\.me|
836 voca\.tube|
837 video\.heromuster\.com|
838 video\.lemediatv\.fr|
839 video\.up\.edu\.ph|
840 balafon\.video|
841 video\.ivel\.fr|
842 thickrips\.cloud|
843 pt\.laurentkruger\.fr|
844 video\.monarch-pass\.net|
845 peertube\.artica\.center|
846 video\.alternanet\.fr|
847 indymotion\.fr|
848 fanvid\.stopthatimp\.net|
849 video\.farci\.org|
850 v\.lesterpig\.com|
851 video\.okaris\.de|
852 tube\.pawelko\.net|
853 peertube\.mablr\.org|
854 tube\.fede\.re|
855 pytu\.be|
856 evertron\.tv|
857 devtube\.dev-wiki\.de|
858 raptube\.antipub\.org|
859 video\.selea\.se|
860 peertube\.mygaia\.org|
861 video\.oh14\.de|
862 peertube\.livingutopia\.org|
863 peertube\.the-penguin\.de|
864 tube\.thechangebook\.org|
865 tube\.anjara\.eu|
866 pt\.pube\.tk|
867 video\.samedi\.pm|
868 mplayer\.demouliere\.eu|
869 widemus\.de|
870 peertube\.me|
871 peertube\.zapashcanon\.fr|
872 video\.latavernedejohnjohn\.fr|
873 peertube\.pcservice46\.fr|
874 peertube\.mazzonetto\.eu|
875 video\.irem\.univ-paris-diderot\.fr|
876 video\.livecchi\.cloud|
877 alttube\.fr|
878 video\.coop\.tools|
879 video\.cabane-libre\.org|
880 peertube\.openstreetmap\.fr|
881 videos\.alolise\.org|
882 irrsinn\.video|
883 video\.antopie\.org|
884 scitech\.video|
885 tube2\.nemsia\.org|
886 video\.amic37\.fr|
887 peertube\.freeforge\.eu|
888 video\.arbitrarion\.com|
889 video\.datsemultimedia\.com|
890 stoptrackingus\.tv|
891 peertube\.ricostrongxxx\.com|
892 docker\.videos\.lecygnenoir\.info|
893 peertube\.togart\.de|
894 tube\.postblue\.info|
895 videos\.domainepublic\.net|
896 peertube\.cyber-tribal\.com|
897 video\.gresille\.org|
898 peertube\.dsmouse\.net|
899 cinema\.yunohost\.support|
900 tube\.theocevaer\.fr|
901 repro\.video|
902 tube\.4aem\.com|
903 quaziinc\.com|
904 peertube\.metawurst\.space|
905 videos\.wakapo\.com|
906 video\.ploud\.fr|
907 video\.freeradical\.zone|
908 tube\.valinor\.fr|
909 refuznik\.video|
910 pt\.kircheneuenburg\.de|
911 peertube\.asrun\.eu|
912 peertube\.lagob\.fr|
913 videos\.side-ways\.net|
914 91video\.online|
915 video\.valme\.io|
916 video\.taboulisme\.com|
917 videos-libr\.es|
918 tv\.mooh\.fr|
919 nuage\.acostey\.fr|
920 video\.monsieur-a\.fr|
921 peertube\.librelois\.fr|
922 videos\.pair2jeux\.tube|
923 videos\.pueseso\.club|
924 peer\.mathdacloud\.ovh|
925 media\.assassinate-you\.net|
926 vidcommons\.org|
927 ptube\.rousset\.nom\.fr|
928 tube\.cyano\.at|
929 videos\.squat\.net|
930 video\.iphodase\.fr|
931 peertube\.makotoworkshop\.org|
932 peertube\.serveur\.slv-valbonne\.fr|
933 vault\.mle\.party|
934 hostyour\.tv|
935 videos\.hack2g2\.fr|
936 libre\.tube|
937 pire\.artisanlogiciel\.net|
938 videos\.numerique-en-commun\.fr|
939 video\.netsyms\.com|
940 video\.die-partei\.social|
941 video\.writeas\.org|
942 peertube\.swarm\.solvingmaz\.es|
943 tube\.pericoloso\.ovh|
944 watching\.cypherpunk\.observer|
945 videos\.adhocmusic\.com|
946 tube\.rfc1149\.net|
947 peertube\.librelabucm\.org|
948 videos\.numericoop\.fr|
949 peertube\.koehn\.com|
950 peertube\.anarchmusicall\.net|
951 tube\.kampftoast\.de|
952 vid\.y-y\.li|
953 peertube\.xtenz\.xyz|
954 diode\.zone|
955 tube\.egf\.mn|
956 peertube\.nomagic\.uk|
957 visionon\.tv|
958 videos\.koumoul\.com|
959 video\.rastapuls\.com|
960 video\.mantlepro\.com|
961 video\.deadsuperhero\.com|
962 peertube\.musicstudio\.pro|
963 peertube\.we-keys\.fr|
964 artitube\.artifaille\.fr|
965 peertube\.ethernia\.net|
966 tube\.midov\.pl|
967 peertube\.fr|
968 watch\.snoot\.tube|
969 peertube\.donnadieu\.fr|
970 argos\.aquilenet\.fr|
971 tube\.nemsia\.org|
972 tube\.bruniau\.net|
973 videos\.darckoune\.moe|
974 tube\.traydent\.info|
975 dev\.videos\.lecygnenoir\.info|
976 peertube\.nayya\.org|
977 peertube\.live|
978 peertube\.mofgao\.space|
979 video\.lequerrec\.eu|
980 peertube\.amicale\.net|
981 aperi\.tube|
982 tube\.ac-lyon\.fr|
983 video\.lw1\.at|
984 www\.yiny\.org|
985 videos\.pofilo\.fr|
986 tube\.lou\.lt|
987 choob\.h\.etbus\.ch|
988 tube\.hoga\.fr|
989 peertube\.heberge\.fr|
990 video\.obermui\.de|
991 videos\.cloudfrancois\.fr|
992 betamax\.video|
993 video\.typica\.us|
994 tube\.piweb\.be|
995 video\.blender\.org|
996 peertube\.cat|
997 tube\.kdy\.ch|
998 pe\.ertu\.be|
999 peertube\.social|
1000 videos\.lescommuns\.org|
1001 tv\.datamol\.org|
1002 videonaute\.fr|
1003 dialup\.express|
1004 peertube\.nogafa\.org|
1005 megatube\.lilomoino\.fr|
1006 peertube\.tamanoir\.foucry\.net|
1007 peertube\.devosi\.org|
1008 peertube\.1312\.media|
1009 tube\.bootlicker\.party|
1010 skeptikon\.fr|
1011 video\.blueline\.mg|
1012 tube\.homecomputing\.fr|
1013 tube\.ouahpiti\.info|
1014 video\.tedomum\.net|
1015 video\.g3l\.org|
1016 fontube\.fr|
1017 peertube\.gaialabs\.ch|
1018 tube\.kher\.nl|
1019 peertube\.qtg\.fr|
1020 video\.migennes\.net|
1021 tube\.p2p\.legal|
1022 troll\.tv|
1023 videos\.iut-orsay\.fr|
1024 peertube\.solidev\.net|
1025 videos\.cemea\.org|
1026 video\.passageenseine\.fr|
1027 videos\.festivalparminous\.org|
1028 peertube\.touhoppai\.moe|
1029 sikke\.fi|
1030 peer\.hostux\.social|
1031 share\.tube|
1032 peertube\.walkingmountains\.fr|
1033 videos\.benpro\.fr|
1034 peertube\.parleur\.net|
1035 peertube\.heraut\.eu|
1036 tube\.aquilenet\.fr|
1037 peertube\.gegeweb\.eu|
1038 framatube\.org|
1039 thinkerview\.video|
1040 tube\.conferences-gesticulees\.net|
1041 peertube\.datagueule\.tv|
1042 video\.lqdn\.fr|
1043 tube\.mochi\.academy|
1044 media\.zat\.im|
1045 video\.colibris-outilslibres\.org|
1046 tube\.svnet\.fr|
1047 peertube\.video|
1048 peertube2\.cpy\.re|
1049 peertube3\.cpy\.re|
1050 videos\.tcit\.fr|
1051 peertube\.cpy\.re|
1052 canard\.tube
1053 )'''
1054 _UUID_RE = r'[\da-zA-Z]{22}|[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}'
1055 _API_BASE = 'https://%s/api/v1/videos/%s/%s'
1056 _VALID_URL = r'''(?x)
1057 (?:
1058 peertube:(?P<host>[^:]+):|
1059 https?://(?P<host_2>%s)/(?:videos/(?:watch|embed)|api/v\d/videos|w)/
1060 )
1061 (?P<id>%s)
1062 ''' % (_INSTANCES_RE, _UUID_RE)
1063 _TESTS = [{
1064 'url': 'https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d',
1065 'md5': '8563064d245a4be5705bddb22bb00a28',
1066 'info_dict': {
1067 'id': '9c9de5e8-0a1e-484a-b099-e80766180a6d',
1068 'ext': 'mp4',
1069 'title': 'What is PeerTube?',
1070 'description': 'md5:3fefb8dde2b189186ce0719fda6f7b10',
1071 'thumbnail': r're:https?://.*\.(?:jpg|png)',
1072 'timestamp': 1538391166,
1073 'upload_date': '20181001',
1074 'uploader': 'Framasoft',
1075 'uploader_id': '3',
1076 'uploader_url': 'https://framatube.org/accounts/framasoft',
1077 'channel': 'A propos de PeerTube',
1078 'channel_id': '2215',
1079 'channel_url': 'https://framatube.org/video-channels/joinpeertube',
1080 'language': 'en',
1081 'license': 'Attribution - Share Alike',
1082 'duration': 113,
1083 'view_count': int,
1084 'like_count': int,
1085 'dislike_count': int,
1086 'tags': ['framasoft', 'peertube'],
1087 'categories': ['Science & Technology'],
1088 }
1089 }, {
1090 'url': 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
1091 'info_dict': {
1092 'id': '122d093a-1ede-43bd-bd34-59d2931ffc5e',
1093 'ext': 'mp4',
1094 'title': 'E2E tests',
1095 'uploader_id': '37855',
1096 'timestamp': 1589276219,
1097 'upload_date': '20200512',
1098 'uploader': 'chocobozzz',
1099 }
1100 }, {
1101 'url': 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',
1102 'info_dict': {
1103 'id': '3fbif9S3WmtTP8gGsC5HBd',
1104 'ext': 'mp4',
1105 'title': 'E2E tests',
1106 'uploader_id': '37855',
1107 'timestamp': 1589276219,
1108 'upload_date': '20200512',
1109 'uploader': 'chocobozzz',
1110 },
1111 }, {
1112 'url': 'https://peertube2.cpy.re/api/v1/videos/3fbif9S3WmtTP8gGsC5HBd',
1113 'info_dict': {
1114 'id': '3fbif9S3WmtTP8gGsC5HBd',
1115 'ext': 'mp4',
1116 'title': 'E2E tests',
1117 'uploader_id': '37855',
1118 'timestamp': 1589276219,
1119 'upload_date': '20200512',
1120 'uploader': 'chocobozzz',
1121 },
1122 }, {
1123 # Issue #26002
1124 'url': 'peertube:spacepub.space:d8943b2d-8280-497b-85ec-bc282ec2afdc',
1125 'info_dict': {
1126 'id': 'd8943b2d-8280-497b-85ec-bc282ec2afdc',
1127 'ext': 'mp4',
1128 'title': 'Dot matrix printer shell demo',
1129 'uploader_id': '3',
1130 'timestamp': 1587401293,
1131 'upload_date': '20200420',
1132 'uploader': 'Drew DeVault',
1133 }
1134 }, {
1135 'url': 'https://peertube.debian.social/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
1136 'only_matching': True,
1137 }, {
1138 # nsfw
1139 'url': 'https://vod.ksite.de/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
1140 'only_matching': True,
1141 }, {
1142 'url': 'https://vod.ksite.de/videos/embed/fed67262-6edb-4d1c-833b-daa9085c71d7',
1143 'only_matching': True,
1144 }, {
1145 'url': 'https://peertube.tv/api/v1/videos/c1875674-97d0-4c94-a058-3f7e64c962e8',
1146 'only_matching': True,
1147 }, {
1148 'url': 'peertube:framatube.org:b37a5b9f-e6b5-415c-b700-04a5cd6ec205',
1149 'only_matching': True,
1150 }]
1151
1152 @staticmethod
1153 def _extract_peertube_url(webpage, source_url):
1154 mobj = re.match(
1155 r'https?://(?P<host>[^/]+)/(?:videos/(?:watch|embed)|w)/(?P<id>%s)'
1156 % PeerTubeIE._UUID_RE, source_url)
1157 if mobj and any(p in webpage for p in (
1158 'meta property="og:platform" content="PeerTube"',
1159 '<title>PeerTube<',
1160 'There will be other non JS-based clients to access PeerTube',
1161 '>We are sorry but it seems that PeerTube is not compatible with your web browser.<')):
1162 return 'peertube:%s:%s' % mobj.group('host', 'id')
1163
1164 @staticmethod
1165 def _extract_urls(webpage, source_url):
1166 entries = re.findall(
1167 r'''(?x)<iframe[^>]+\bsrc=["\'](?P<url>(?:https?:)?//%s/videos/embed/%s)'''
1168 % (PeerTubeIE._INSTANCES_RE, PeerTubeIE._UUID_RE), webpage)
1169 if not entries:
1170 peertube_url = PeerTubeIE._extract_peertube_url(webpage, source_url)
1171 if peertube_url:
1172 entries = [peertube_url]
1173 return entries
1174
1175 def _call_api(self, host, video_id, path, note=None, errnote=None, fatal=True):
1176 return self._download_json(
1177 self._API_BASE % (host, video_id, path), video_id,
1178 note=note, errnote=errnote, fatal=fatal)
1179
1180 def _get_subtitles(self, host, video_id):
1181 captions = self._call_api(
1182 host, video_id, 'captions', note='Downloading captions JSON',
1183 fatal=False)
1184 if not isinstance(captions, dict):
1185 return
1186 data = captions.get('data')
1187 if not isinstance(data, list):
1188 return
1189 subtitles = {}
1190 for e in data:
1191 language_id = try_get(e, lambda x: x['language']['id'], compat_str)
1192 caption_url = urljoin('https://%s' % host, e.get('captionPath'))
1193 if not caption_url:
1194 continue
1195 subtitles.setdefault(language_id or 'en', []).append({
1196 'url': caption_url,
1197 })
1198 return subtitles
1199
1200 def _real_extract(self, url):
1201 mobj = self._match_valid_url(url)
1202 host = mobj.group('host') or mobj.group('host_2')
1203 video_id = mobj.group('id')
1204
1205 video = self._call_api(
1206 host, video_id, '', note='Downloading video JSON')
1207
1208 title = video['name']
1209
1210 formats = []
1211 files = video.get('files') or []
1212 for playlist in (video.get('streamingPlaylists') or []):
1213 if not isinstance(playlist, dict):
1214 continue
1215 playlist_files = playlist.get('files')
1216 if not (playlist_files and isinstance(playlist_files, list)):
1217 continue
1218 files.extend(playlist_files)
1219 for file_ in files:
1220 if not isinstance(file_, dict):
1221 continue
1222 file_url = url_or_none(file_.get('fileUrl'))
1223 if not file_url:
1224 continue
1225 file_size = int_or_none(file_.get('size'))
1226 format_id = try_get(
1227 file_, lambda x: x['resolution']['label'], compat_str)
1228 f = parse_resolution(format_id)
1229 f.update({
1230 'url': file_url,
1231 'format_id': format_id,
1232 'filesize': file_size,
1233 })
1234 if format_id == '0p':
1235 f['vcodec'] = 'none'
1236 else:
1237 f['fps'] = int_or_none(file_.get('fps'))
1238 formats.append(f)
1239 self._sort_formats(formats)
1240
1241 description = video.get('description')
1242 if description and len(description) >= 250:
1243 # description is shortened
1244 full_description = self._call_api(
1245 host, video_id, 'description', note='Downloading description JSON',
1246 fatal=False)
1247
1248 if isinstance(full_description, dict):
1249 description = str_or_none(full_description.get('description')) or description
1250
1251 subtitles = self.extract_subtitles(host, video_id)
1252
1253 def data(section, field, type_):
1254 return try_get(video, lambda x: x[section][field], type_)
1255
1256 def account_data(field, type_):
1257 return data('account', field, type_)
1258
1259 def channel_data(field, type_):
1260 return data('channel', field, type_)
1261
1262 category = data('category', 'label', compat_str)
1263 categories = [category] if category else None
1264
1265 nsfw = video.get('nsfw')
1266 if nsfw is bool:
1267 age_limit = 18 if nsfw else 0
1268 else:
1269 age_limit = None
1270
1271 webpage_url = 'https://%s/videos/watch/%s' % (host, video_id)
1272
1273 return {
1274 'id': video_id,
1275 'title': title,
1276 'description': description,
1277 'thumbnail': urljoin(webpage_url, video.get('thumbnailPath')),
1278 'timestamp': unified_timestamp(video.get('publishedAt')),
1279 'uploader': account_data('displayName', compat_str),
1280 'uploader_id': str_or_none(account_data('id', int)),
1281 'uploader_url': url_or_none(account_data('url', compat_str)),
1282 'channel': channel_data('displayName', compat_str),
1283 'channel_id': str_or_none(channel_data('id', int)),
1284 'channel_url': url_or_none(channel_data('url', compat_str)),
1285 'language': data('language', 'id', compat_str),
1286 'license': data('licence', 'label', compat_str),
1287 'duration': int_or_none(video.get('duration')),
1288 'view_count': int_or_none(video.get('views')),
1289 'like_count': int_or_none(video.get('likes')),
1290 'dislike_count': int_or_none(video.get('dislikes')),
1291 'age_limit': age_limit,
1292 'tags': try_get(video, lambda x: x['tags'], list),
1293 'categories': categories,
1294 'formats': formats,
1295 'subtitles': subtitles,
1296 'webpage_url': webpage_url,
1297 }
1298
1299
1300 class PeerTubePlaylistIE(InfoExtractor):
1301 IE_NAME = 'PeerTube:Playlist'
1302 _TYPES = {
1303 'a': 'accounts',
1304 'c': 'video-channels',
1305 'w/p': 'video-playlists',
1306 }
1307 _VALID_URL = r'''(?x)
1308 https?://(?P<host>%s)/(?P<type>(?:%s))/
1309 (?P<id>[^/]+)
1310 ''' % (PeerTubeIE._INSTANCES_RE, '|'.join(_TYPES.keys()))
1311 _TESTS = [{
1312 'url': 'https://peertube.tux.ovh/w/p/3af94cba-95e8-4b74-b37a-807ab6d82526',
1313 'info_dict': {
1314 'id': '3af94cba-95e8-4b74-b37a-807ab6d82526',
1315 'description': 'playlist',
1316 'timestamp': 1611171863,
1317 'title': 'playlist',
1318 },
1319 'playlist_mincount': 6,
1320 }, {
1321 'url': 'https://peertube.tux.ovh/w/p/wkyqcQBnsvFxtUB2pkYc1e',
1322 'info_dict': {
1323 'id': 'wkyqcQBnsvFxtUB2pkYc1e',
1324 'description': 'Cette liste de vidéos contient uniquement les jeux qui peuvent être terminés en une seule vidéo.',
1325 'title': 'Let\'s Play',
1326 'timestamp': 1604147331,
1327 },
1328 'playlist_mincount': 6,
1329 }, {
1330 'url': 'https://peertube.debian.social/w/p/hFdJoTuyhNJVa1cDWd1d12',
1331 'info_dict': {
1332 'id': 'hFdJoTuyhNJVa1cDWd1d12',
1333 'description': 'Diversas palestras do Richard Stallman no Brasil.',
1334 'title': 'Richard Stallman no Brasil',
1335 'timestamp': 1599676222,
1336 },
1337 'playlist_mincount': 9,
1338 }, {
1339 'url': 'https://peertube2.cpy.re/a/chocobozzz/videos',
1340 'info_dict': {
1341 'id': 'chocobozzz',
1342 'timestamp': 1553874564,
1343 'title': 'chocobozzz',
1344 },
1345 'playlist_mincount': 2,
1346 }, {
1347 'url': 'https://framatube.org/c/bf54d359-cfad-4935-9d45-9d6be93f63e8/videos',
1348 'info_dict': {
1349 'id': 'bf54d359-cfad-4935-9d45-9d6be93f63e8',
1350 'timestamp': 1519917377,
1351 'title': 'Les vidéos de Framasoft',
1352 },
1353 'playlist_mincount': 345,
1354 }, {
1355 'url': 'https://peertube2.cpy.re/c/blender_open_movies@video.blender.org/videos',
1356 'info_dict': {
1357 'id': 'blender_open_movies@video.blender.org',
1358 'timestamp': 1542287810,
1359 'title': 'Official Blender Open Movies',
1360 },
1361 'playlist_mincount': 11,
1362 }]
1363 _API_BASE = 'https://%s/api/v1/%s/%s%s'
1364 _PAGE_SIZE = 30
1365
1366 def call_api(self, host, name, path, base, **kwargs):
1367 return self._download_json(
1368 self._API_BASE % (host, base, name, path), name, **kwargs)
1369
1370 def fetch_page(self, host, id, type, page):
1371 page += 1
1372 video_data = self.call_api(
1373 host, id,
1374 f'/videos?sort=-createdAt&start={self._PAGE_SIZE * (page - 1)}&count={self._PAGE_SIZE}&nsfw=both',
1375 type, note=f'Downloading page {page}').get('data', [])
1376 for video in video_data:
1377 shortUUID = video.get('shortUUID') or try_get(video, lambda x: x['video']['shortUUID'])
1378 video_title = video.get('name') or try_get(video, lambda x: x['video']['name'])
1379 yield self.url_result(
1380 f'https://{host}/w/{shortUUID}', PeerTubeIE.ie_key(),
1381 video_id=shortUUID, video_title=video_title)
1382
1383 def _extract_playlist(self, host, type, id):
1384 info = self.call_api(host, id, '', type, note='Downloading playlist information', fatal=False)
1385
1386 playlist_title = info.get('displayName')
1387 playlist_description = info.get('description')
1388 playlist_timestamp = unified_timestamp(info.get('createdAt'))
1389 channel = try_get(info, lambda x: x['ownerAccount']['name']) or info.get('displayName')
1390 channel_id = try_get(info, lambda x: x['ownerAccount']['id']) or info.get('id')
1391 thumbnail = format_field(info, 'thumbnailPath', f'https://{host}%s')
1392
1393 entries = OnDemandPagedList(functools.partial(
1394 self.fetch_page, host, id, type), self._PAGE_SIZE)
1395
1396 return self.playlist_result(
1397 entries, id, playlist_title, playlist_description,
1398 timestamp=playlist_timestamp, channel=channel, channel_id=channel_id, thumbnail=thumbnail)
1399
1400 def _real_extract(self, url):
1401 type, host, id = self._match_valid_url(url).group('type', 'host', 'id')
1402 type = self._TYPES[type]
1403 return self._extract_playlist(host, type, id)