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