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