]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/peertube.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..compat
import compat_str
21 class PeerTubeIE(InfoExtractor
):
22 _INSTANCES_RE
= r
'''(?:
23 # Taken from https://instances.joinpeertube.org/instances
30 archive\.vidicon\.org|
40 clap\.nerv-project\.eu|
41 climatejustice\.video|
43 conspiracydistillery\.com|
44 darkvapor\.nohost\.me|
45 daschauher\.aksel\.rocks|
46 digitalcourage\.video|
47 dreiecksnebel\.alex-detsch\.de|
55 fotogramas\.politicaconciencia\.org|
60 grypstube\.uni-greifswald\.de|
69 kirche\.peertube-host\.de|
75 lepetitmayennais\.fr\.nf|
84 lolitube\.freedomchan\.moe|
85 lucarne\.balsamine\.be|
90 media\.inno3\.cricket|
92 media\.krashboyz\.org|
93 media\.over-world\.org|
95 media\.undeadnetwork\.de|
96 medias\.pingbase\.net|
97 melsungen\.peertube-host\.de|
100 monplaisirtube\.ddns\.net|
104 mytube\.kn-cloud\.de|
106 myworkoutarenapeertube\.cf|
107 nanawel-peertube\.dyndns\.org|
111 ovaltube\.codinglab\.ch|
116 peertube1\.zeteo\.me|
119 peertube\.alpharius\.io|
120 peertube\.am-networks\.fr|
121 peertube\.anduin\.net|
122 peertube\.anzui\.dev|
123 peertube\.arbleizez\.bzh|
124 peertube\.art3mis\.de|
125 peertube\.atilla\.org|
126 peertube\.atsuchan\.page|
127 peertube\.aukfood\.net|
128 peertube\.aventer\.biz|
129 peertube\.b38\.rural-it\.org|
130 peertube\.beeldengeluid\.nl|
132 peertube\.bgzashtita\.es|
133 peertube\.bitsandlinux\.com|
135 peertube\.boba\.best|
137 peertube\.bridaahost\.ynh\.fr|
138 peertube\.bubbletea\.dev|
139 peertube\.bubuit\.net|
140 peertube\.cabaal\.net|
141 peertube\.cats-home\.net|
142 peertube\.chemnitz\.freifunk\.net|
143 peertube\.chevro\.fr|
144 peertube\.chrisspiegl\.com|
145 peertube\.chtisurel\.net|
146 peertube\.cipherbliss\.com|
147 peertube\.cloud\.sans\.pub|
148 peertube\.cpge-brizeux\.fr|
149 peertube\.ctseuro\.com|
150 peertube\.cuatrolibertades\.org|
151 peertube\.cybercirujas\.club|
152 peertube\.cythin\.com|
153 peertube\.davigge\.com|
154 peertube\.dc\.pini\.fr|
155 peertube\.debian\.social|
156 peertube\.demonix\.fr|
157 peertube\.designersethiques\.org|
159 peertube\.devloprog\.org|
162 peertube\.ecologie\.bzh|
164 peertube\.european-pirates\.eu|
165 peertube\.euskarabildua\.eus|
166 peertube\.fenarinarsa\.com|
167 peertube\.fomin\.site|
168 peertube\.forsud\.be|
169 peertube\.francoispelletier\.org|
170 peertube\.freenet\.ru|
171 peertube\.freetalklive\.com|
172 peertube\.functional\.cafe|
173 peertube\.gardeludwig\.fr|
174 peertube\.gargantia\.fr|
175 peertube\.gcfamily\.fr|
177 peertube\.get-racing\.de|
178 peertube\.gidikroon\.eu|
179 peertube\.gruezishop\.ch|
180 peertube\.habets\.house|
181 peertube\.hackerfraternity\.org|
182 peertube\.ichigo\.everydayimshuflin\.com|
183 peertube\.ignifi\.me|
184 peertube\.inapurna\.org|
185 peertube\.informaction\.info|
186 peertube\.interhop\.org|
187 peertube\.iselfhost\.com|
189 peertube\.jensdiemer\.de|
190 peertube\.joffreyverd\.fr|
192 peertube\.kathryl\.fr|
193 peertube\.keazilla\.net|
194 peertube\.klaewyss\.fr|
195 peertube\.kodcast\.com|
196 peertube\.kx\.studio|
197 peertube\.lagvoid\.com|
198 peertube\.lavallee\.tech|
199 peertube\.le5emeaxe\.fr|
200 peertube\.lestutosdeprocessus\.fr|
201 peertube\.librenet\.co\.za|
202 peertube\.logilab\.fr|
203 peertube\.louisematic\.site|
204 peertube\.luckow\.org|
206 peertube\.lyceeconnecte\.fr|
207 peertube\.manalejandro\.com|
209 peertube\.mattone\.net|
210 peertube\.maxweiss\.io|
211 peertube\.monlycee\.net|
212 peertube\.mxinfo\.fr|
213 peertube\.myrasp\.eu|
214 peertube\.nebelcloud\.de|
215 peertube\.netzbegruenung\.de|
216 peertube\.newsocial\.tech|
217 peertube\.nicolastissot\.fr|
219 peertube\.offerman\.com|
220 peertube\.opencloud\.lu|
221 peertube\.orthus\.link|
222 peertube\.patapouf\.xyz|
224 peertube\.plataformess\.org|
226 peertube\.portaesgnos\.org|
227 peertube\.r2\.enst\.fr|
229 peertube\.radres\.xyz|
231 peertube\.robonomics\.network|
232 peertube\.rtnkv\.cloud|
233 peertube\.runfox\.tk|
234 peertube\.satoshishop\.de|
235 peertube\.scic-tetris\.org|
236 peertube\.securitymadein\.lu|
237 peertube\.semweb\.pro|
238 peertube\.social\.my-wan\.de|
239 peertube\.soykaf\.org|
240 peertube\.stefofficiel\.me|
244 peertube\.takeko\.cyou|
245 peertube\.tangentfox\.com|
246 peertube\.taxinachtegel\.de|
247 peertube\.thenewoil\.xyz|
248 peertube\.ti-fr\.com|
249 peertube\.tiennot\.net|
250 peertube\.troback\.com|
251 peertube\.tspu\.edu\.ru|
256 peertube\.underworld\.fr|
258 peertube\.ventresmous\.fr|
260 peertube\.w\.utnw\.de|
261 peertube\.westring\.digital|
262 peertube\.xwiki\.com|
263 peertube\.zoz-serv\.org|
265 periscope\.numenaute\.org|
267 petitlutinartube\.fr|
272 player\.ojamajo\.moe|
274 pocketnetpeertube1\.nohost\.me|
275 pocketnetpeertube3\.nohost\.me|
276 pocketnetpeertube4\.nohost\.me|
277 pocketnetpeertube5\.nohost\.me|
278 pocketnetpeertube6\.nohost\.me|
284 ptb\.lunarviews\.net|
285 ptmir1\.inter21\.net|
286 ptmir2\.inter21\.net|
287 ptmir3\.inter21\.net|
288 ptmir4\.inter21\.net|
289 ptmir5\.inter21\.net|
290 ptube\.horsentiers\.fr|
291 ptube\.xmanifesto\.club|
293 re-wizja\.re-medium\.com|
299 sender-fm\.veezee\.tube|
300 serv1\.wiki-tube\.de|
301 serv3\.wiki-tube\.de|
308 stream\.shahab\.nohost\.me|
310 studios\.racer159\.com|
311 testtube\.florimond\.eu|
312 tgi\.hosted\.spacebear\.ee|
315 theater\.ethernia\.net|
322 tube-aix-marseille\.beta\.education\.fr|
323 tube-amiens\.beta\.education\.fr|
324 tube-besancon\.beta\.education\.fr|
325 tube-bordeaux\.beta\.education\.fr|
326 tube-clermont-ferrand\.beta\.education\.fr|
327 tube-corse\.beta\.education\.fr|
328 tube-creteil\.beta\.education\.fr|
329 tube-dijon\.beta\.education\.fr|
330 tube-education\.beta\.education\.fr|
331 tube-grenoble\.beta\.education\.fr|
332 tube-lille\.beta\.education\.fr|
333 tube-limoges\.beta\.education\.fr|
334 tube-montpellier\.beta\.education\.fr|
335 tube-nancy\.beta\.education\.fr|
336 tube-nantes\.beta\.education\.fr|
337 tube-nice\.beta\.education\.fr|
338 tube-normandie\.beta\.education\.fr|
339 tube-orleans-tours\.beta\.education\.fr|
340 tube-outremer\.beta\.education\.fr|
341 tube-paris\.beta\.education\.fr|
342 tube-poitiers\.beta\.education\.fr|
343 tube-reims\.beta\.education\.fr|
344 tube-rennes\.beta\.education\.fr|
345 tube-strasbourg\.beta\.education\.fr|
346 tube-toulouse\.beta\.education\.fr|
347 tube-versailles\.beta\.education\.fr|
348 tube1\.it\.tuwien\.ac\.at|
349 tube\.abolivier\.bzh|
351 tube\.aerztefueraufklaerung\.de|
368 tube\.cloud-libre\.eu|
371 tube\.cryptography\.dog|
372 tube\.darknight-coffee\.org|
375 tube\.dsocialize\.net|
381 tube\.frischesicht\.de|
387 tube\.hackerscop\.org|
390 tube\.kai-stuht\.com|
393 tube\.lacaveatonton\.ovh|
396 tube\.lucie-philou\.com|
397 tube\.melonbread\.xyz|
405 tube\.nuagelibre\.fr|
410 tube\.opportunis\.me|
413 tube\.others\.social|
415 tube\.plomlompom\.com|
417 tube\.portes-imaginaire\.org|
419 tube\.rebellion\.global|
420 tube\.rhythms-of-resistance\.org|
425 tube\.schleuss\.online|
426 tube\.schule\.social|
433 tube\.superseriousbusiness\.org|
439 tube\.troopers\.agency|
440 tube\.tylerdavis\.xyz|
442 tube\.vigilian-consulting\.nl|
455 tuvideo\.encanarias\.info|
462 tv\.generallyrubbish\.net\.au|
464 tv\.mattchristiansenmedia\.com|
465 tv\.netwhood\.online|
468 tv\.pirateradio\.social|
471 twctube\.twc-zone\.eu|
485 vid\.pravdastalina\.info|
487 vid\.rajeshtaylor\.com|
488 vid\.samtripoli\.com|
493 video\.1146\.nohost\.me|
494 video\.altertek\.org|
495 video\.anartist\.org|
496 video\.apps\.thedoodleproject\.net|
498 video\.asgardius\.company|
499 video\.balsillie\.net|
500 video\.bards\.online|
501 video\.binarydad\.com|
502 video\.blast-info\.fr|
504 video\.cigliola\.com|
505 video\.cm-en-transition\.fr|
508 video\.codingfield\.com|
509 video\.comptoir\.net|
510 video\.comune\.trento\.it|
514 video\.demokratischer-sommer\.de|
515 video\.discord-insoumis\.fr|
516 video\.dolphincastle\.com|
517 video\.dresden\.network|
518 video\.ecole-89\.com|
519 video\.elgrillolibertario\.org|
520 video\.emergeheart\.info|
521 video\.eradicatinglove\.xyz|
522 video\.ethantheenigma\.me|
523 video\.exodus-privacy\.eu\.org|
526 video\.greenmycity\.eu|
527 video\.guerredeclasse\.fr|
529 video\.hackers\.town|
530 video\.hardlimit\.com|
533 video\.internet-czas-dzialac\.pl|
534 video\.islameye\.com|
536 video\.kuba-orlik\.name|
537 video\.kyushojitsu\.ca|
539 video\.lespoesiesdheloise\.fr|
542 video\.linc\.systems|
544 video\.linuxtrent\.it|
545 video\.lokal\.social|
549 video\.marcorennmaus\.de|
550 video\.mass-trespass\.uk|
552 video\.mundodesconocido\.com|
555 video\.odayacres\.farm|
556 video\.ozgurkon\.org|
557 video\.p1ng0ut\.social|
560 video\.pony\.gallery|
561 video\.potate\.space|
562 video\.pourpenser\.pro|
563 video\.progressiv\.dev|
564 video\.resolutions\.it|
566 video\.screamer\.wiki|
567 video\.sdm-tools\.net|
569 video\.shitposter\.club|
572 video\.stuartbrand\.co\.uk|
573 video\.thinkof\.name|
577 video\.vaku\.org\.ua|
579 video\.violoncello\.ch|
581 video\.wsf2021\.info|
583 videos-passages\.huma-num\.fr|
584 videos\.3d-wolf\.com|
585 videos\.ahp-numerique\.fr|
586 videos\.alexandrebadalo\.pt|
587 videos\.archigny\.net|
588 videos\.benjaminbrady\.ie|
589 videos\.buceoluegoexisto\.com|
591 videos\.casually\.cat|
592 videos\.cloudron\.io|
593 videos\.coletivos\.org|
594 videos\.danksquad\.org|
595 videos\.denshi\.live|
596 videos\.fromouter\.space|
598 videos\.globenet\.org|
601 videos\.john-livingston\.fr|
602 videos\.jordanwarne\.xyz|
603 videos\.lavoixdessansvoix\.org|
604 videos\.leslionsfloorball\.fr|
606 videos\.martyn\.berlin|
607 videos\.mastodont\.cat|
608 videos\.monstro1\.com|
610 videos\.optoutpod\.com|
611 videos\.petch\.rocks|
612 videos\.pzelawski\.xyz|
614 videos\.scanlines\.xyz|
617 videos\.stadtfabrikanten\.org|
618 videos\.tankernn\.eu|
619 videos\.testimonia\.org|
620 videos\.thisishowidontdisappear\.com|
621 videos\.traumaheilung\.net|
623 videos\.wakkerewereld\.nu|
631 vulgarisation-informatique\.fr|
632 watch\.breadtube\.tv|
633 watch\.deranalyst\.ch|
634 watch\.ignorance\.eu|
636 watch\.libertaria\.space|
638 watch\.softinio\.com|
639 watch\.tubelab\.video|
641 webtv\.vandoeuvre\.net|
647 www4\.mir\.inter21\.net|
648 www\.birkeundnymphe\.de|
649 www\.captain-german\.com|
651 xxivproduction\.video|
655 peertube\.rainbowswingers\.net|
659 videomensoif\.ynh\.fr|
660 peertube\.travelpandas\.eu|
661 peertube\.rachetjay\.fr|
662 peertube\.montecsys\.fr|
665 peertube\.umeahackerspace\.se|
667 video\.monsieurbidouille\.fr|
668 tube\.openalgeria\.org|
670 video\.anormallostpod\.ovh|
671 tube\.crapaud-fou\.org|
675 peertube\.snargol\.com|
680 peertube\.osureplayviewer\.xyz|
681 peertube\.mathieufamily\.ovh|
682 www\.videos-libr\.es|
684 peertube\.fediverse\.ru|
685 peertube\.oiseauroch\.fr|
693 peertube\.chantierlibre\.org|
699 videos\.elbinario\.net|
705 peertube\.gnumeria\.eu\.org|
709 tube\.kalah-france\.org|
713 peertube\.hatthieves\.es|
714 video\.fitchfamily\.org|
718 tube\.22decembre\.eu|
719 peertube\.harmoniescreatives\.com|
721 video\.thedwyers\.co|
722 video\.bruitbruit\.com|
723 peertube\.foxfam\.club|
725 videos\.bugs\.social|
726 peertube\.malbert\.xyz|
727 peertube\.bilange\.ca|
730 peertube\.fedilab\.app|
732 video\.mstddntfdn\.online|
734 peertube\.sl-network\.fr|
735 peertube\.dynlinux\.io|
736 peertube\.david\.durieux\.family|
737 peertube\.linuxrocks\.online|
739 v\.kretschmann\.social|
742 tube\.dragonpsi\.xyz|
743 peertube\.boneheadmedia\.com|
744 videos\.funkwhale\.audio|
746 peertube\.gcaillaut\.fr|
753 peertube\.simounet\.net|
757 peertube\.kerenon\.com|
759 tube\.calculate\.social|
760 peertube\.mckillop\.org|
761 tube\.netzspielplatz\.de|
765 peertube\.stephenson\.cc|
767 peertube\.kajalinifi\.de|
770 peertube\.ffs2play\.fr|
771 peertube\.leboulaire\.ovh|
772 peertube\.tronic-studio\.com|
773 peertube\.public\.cat|
774 peertube\.metalbanana\.net|
776 peertube\.alter-nativ-voll\.de|
778 tube\.worldofhauru\.xyz|
780 peertube\.teleassist\.fr|
783 media\.privacyinternational\.org|
785 video\.halle-leaks\.de|
786 video\.grosskopfgames\.de|
787 peertube\.schaeferit\.de|
788 peertube\.jackbot\.fr|
789 tube\.extinctionrebellion\.fr|
793 peertube\.zergy\.net|
794 peertube\.roflcopter\.fr|
795 peertube\.floss-marketing-school\.com|
797 peertube\.iriseden\.eu|
798 videos\.ubuntu-paris\.org|
799 peertube\.mastodon\.host|
801 peertube\.s2s\.video|
806 peertube\.normandie-libre\.fr|
808 video\.lacaveatonton\.ovh|
810 peertube\.servebeer\.com|
811 peertube\.fedi\.quebec|
816 tube\.unmondemeilleur\.eu|
823 video\.devinberg\.com|
825 peertube\.kosebamse\.com|
826 yunopeertube\.myddns\.me|
827 peertube\.varney\.fr|
828 peertube\.anon-kenkai\.com|
831 videos\.dinofly\.com|
835 video\.heromuster\.com|
836 video\.lemediatv\.fr|
841 pt\.laurentkruger\.fr|
842 video\.monarch-pass\.net|
843 peertube\.artica\.center|
844 video\.alternanet\.fr|
846 fanvid\.stopthatimp\.net|
851 peertube\.mablr\.org|
855 devtube\.dev-wiki\.de|
856 raptube\.antipub\.org|
858 peertube\.mygaia\.org|
860 peertube\.livingutopia\.org|
861 peertube\.the-penguin\.de|
862 tube\.thechangebook\.org|
866 mplayer\.demouliere\.eu|
869 peertube\.zapashcanon\.fr|
870 video\.latavernedejohnjohn\.fr|
871 peertube\.pcservice46\.fr|
872 peertube\.mazzonetto\.eu|
873 video\.irem\.univ-paris-diderot\.fr|
874 video\.livecchi\.cloud|
877 video\.cabane-libre\.org|
878 peertube\.openstreetmap\.fr|
879 videos\.alolise\.org|
885 peertube\.freeforge\.eu|
886 video\.arbitrarion\.com|
887 video\.datsemultimedia\.com|
889 peertube\.ricostrongxxx\.com|
890 docker\.videos\.lecygnenoir\.info|
891 peertube\.togart\.de|
892 tube\.postblue\.info|
893 videos\.domainepublic\.net|
894 peertube\.cyber-tribal\.com|
895 video\.gresille\.org|
896 peertube\.dsmouse\.net|
897 cinema\.yunohost\.support|
898 tube\.theocevaer\.fr|
902 peertube\.metawurst\.space|
905 video\.freeradical\.zone|
908 pt\.kircheneuenburg\.de|
911 videos\.side-ways\.net|
914 video\.taboulisme\.com|
918 video\.monsieur-a\.fr|
919 peertube\.librelois\.fr|
920 videos\.pair2jeux\.tube|
921 videos\.pueseso\.club|
922 peer\.mathdacloud\.ovh|
923 media\.assassinate-you\.net|
925 ptube\.rousset\.nom\.fr|
929 peertube\.makotoworkshop\.org|
930 peertube\.serveur\.slv-valbonne\.fr|
935 pire\.artisanlogiciel\.net|
936 videos\.numerique-en-commun\.fr|
938 video\.die-partei\.social|
940 peertube\.swarm\.solvingmaz\.es|
941 tube\.pericoloso\.ovh|
942 watching\.cypherpunk\.observer|
943 videos\.adhocmusic\.com|
945 peertube\.librelabucm\.org|
946 videos\.numericoop\.fr|
947 peertube\.koehn\.com|
948 peertube\.anarchmusicall\.net|
949 tube\.kampftoast\.de|
951 peertube\.xtenz\.xyz|
954 peertube\.nomagic\.uk|
956 videos\.koumoul\.com|
957 video\.rastapuls\.com|
958 video\.mantlepro\.com|
959 video\.deadsuperhero\.com|
960 peertube\.musicstudio\.pro|
961 peertube\.we-keys\.fr|
962 artitube\.artifaille\.fr|
963 peertube\.ethernia\.net|
967 peertube\.donnadieu\.fr|
968 argos\.aquilenet\.fr|
971 videos\.darckoune\.moe|
972 tube\.traydent\.info|
973 dev\.videos\.lecygnenoir\.info|
974 peertube\.nayya\.org|
976 peertube\.mofgao\.space|
977 video\.lequerrec\.eu|
978 peertube\.amicale\.net|
987 peertube\.heberge\.fr|
989 videos\.cloudfrancois\.fr|
998 videos\.lescommuns\.org|
1002 peertube\.nogafa\.org|
1003 megatube\.lilomoino\.fr|
1004 peertube\.tamanoir\.foucry\.net|
1005 peertube\.devosi\.org|
1006 peertube\.1312\.media|
1007 tube\.bootlicker\.party|
1009 video\.blueline\.mg|
1010 tube\.homecomputing\.fr|
1011 tube\.ouahpiti\.info|
1012 video\.tedomum\.net|
1015 peertube\.gaialabs\.ch|
1018 video\.migennes\.net|
1021 videos\.iut-orsay\.fr|
1022 peertube\.solidev\.net|
1024 video\.passageenseine\.fr|
1025 videos\.festivalparminous\.org|
1026 peertube\.touhoppai\.moe|
1028 peer\.hostux\.social|
1030 peertube\.walkingmountains\.fr|
1032 peertube\.parleur\.net|
1033 peertube\.heraut\.eu|
1034 tube\.aquilenet\.fr|
1035 peertube\.gegeweb\.eu|
1038 tube\.conferences-gesticulees\.net|
1039 peertube\.datagueule\.tv|
1041 tube\.mochi\.academy|
1043 video\.colibris-outilslibres\.org|
1052 _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}'
1053 _API_BASE
= 'https://%s/api/v1/videos/%s/%s'
1054 _VALID_URL
= r
'''(?x)
1056 peertube:(?P<host>[^:]+):|
1057 https?://(?P<host_2>%s)/(?:videos/(?:watch|embed)|api/v\d/videos|w)/
1060 ''' % (_INSTANCES_RE
, _UUID_RE
)
1062 'url': 'https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d',
1063 'md5': '8563064d245a4be5705bddb22bb00a28',
1065 'id': '9c9de5e8-0a1e-484a-b099-e80766180a6d',
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',
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',
1079 'license': 'Attribution - Share Alike',
1083 'dislike_count': int,
1084 'tags': ['framasoft', 'peertube'],
1085 'categories': ['Science & Technology'],
1088 'url': 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
1090 'id': '122d093a-1ede-43bd-bd34-59d2931ffc5e',
1092 'title': 'E2E tests',
1093 'uploader_id': '37855',
1094 'timestamp': 1589276219,
1095 'upload_date': '20200512',
1096 'uploader': 'chocobozzz',
1099 'url': 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',
1101 'id': '3fbif9S3WmtTP8gGsC5HBd',
1103 'title': 'E2E tests',
1104 'uploader_id': '37855',
1105 'timestamp': 1589276219,
1106 'upload_date': '20200512',
1107 'uploader': 'chocobozzz',
1110 'url': 'https://peertube2.cpy.re/api/v1/videos/3fbif9S3WmtTP8gGsC5HBd',
1112 'id': '3fbif9S3WmtTP8gGsC5HBd',
1114 'title': 'E2E tests',
1115 'uploader_id': '37855',
1116 'timestamp': 1589276219,
1117 'upload_date': '20200512',
1118 'uploader': 'chocobozzz',
1122 'url': 'peertube:spacepub.space:d8943b2d-8280-497b-85ec-bc282ec2afdc',
1124 'id': 'd8943b2d-8280-497b-85ec-bc282ec2afdc',
1126 'title': 'Dot matrix printer shell demo',
1128 'timestamp': 1587401293,
1129 'upload_date': '20200420',
1130 'uploader': 'Drew DeVault',
1133 'url': 'https://peertube.debian.social/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
1134 'only_matching': True,
1137 'url': 'https://vod.ksite.de/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
1138 'only_matching': True,
1140 'url': 'https://vod.ksite.de/videos/embed/fed67262-6edb-4d1c-833b-daa9085c71d7',
1141 'only_matching': True,
1143 'url': 'https://peertube.tv/api/v1/videos/c1875674-97d0-4c94-a058-3f7e64c962e8',
1144 'only_matching': True,
1146 'url': 'peertube:framatube.org:b37a5b9f-e6b5-415c-b700-04a5cd6ec205',
1147 'only_matching': True,
1151 def _extract_peertube_url(webpage
, source_url
):
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"',
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')
1163 def _extract_urls(webpage
, source_url
):
1164 entries
= re
.findall(
1165 r
'''(?x)<iframe[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//%s/videos
/embed
/%s)'''
1166 % (PeerTubeIE._INSTANCES_RE, PeerTubeIE._UUID_RE), webpage)
1168 peertube_url = PeerTubeIE._extract_peertube_url(webpage, source_url)
1170 entries = [peertube_url]
1173 def _call_api(self, host, video_id, path, note=None, errnote=None, fatal=True):
1174 return self._download_json(
1175 self._API_BASE % (host, video_id, path), video_id,
1176 note=note, errnote=errnote, fatal=fatal)
1178 def _get_subtitles(self, host, video_id):
1179 captions = self._call_api(
1180 host, video_id, 'captions', note='Downloading captions JSON',
1182 if not isinstance(captions, dict):
1184 data = captions.get('data')
1185 if not isinstance(data, list):
1189 language_id = try_get(e, lambda x: x['language']['id'], compat_str)
1190 caption_url = urljoin('https://%s' % host, e.get('captionPath'))
1193 subtitles.setdefault(language_id or 'en', []).append({
1198 def _real_extract(self, url):
1199 mobj = self._match_valid_url(url)
1200 host = mobj.group('host') or mobj.group('host_2')
1201 video_id = mobj.group('id')
1203 video = self._call_api(
1204 host, video_id, '', note='Downloading video JSON')
1206 title = video['name']
1209 files = video.get('files') or []
1210 for playlist in (video.get('streamingPlaylists') or []):
1211 if not isinstance(playlist, dict):
1213 playlist_files = playlist.get('files')
1214 if not (playlist_files and isinstance(playlist_files, list)):
1216 files.extend(playlist_files)
1218 if not isinstance(file_, dict):
1220 file_url = url_or_none(file_.get('fileUrl'))
1223 file_size = int_or_none(file_.get('size'))
1224 format_id = try_get(
1225 file_, lambda x: x['resolution']['label'], compat_str)
1226 f = parse_resolution(format_id)
1229 'format_id': format_id,
1230 'filesize': file_size,
1232 if format_id == '0p':
1233 f['vcodec'] = 'none'
1235 f['fps'] = int_or_none(file_.get('fps'))
1237 self._sort_formats(formats)
1239 description = video.get('description')
1240 if description and len(description) >= 250:
1241 # description is shortened
1242 full_description = self._call_api(
1243 host, video_id, 'description', note='Downloading description JSON',
1246 if isinstance(full_description, dict):
1247 description = str_or_none(full_description.get('description')) or description
1249 subtitles = self.extract_subtitles(host, video_id)
1251 def data(section, field, type_):
1252 return try_get(video, lambda x: x[section][field], type_)
1254 def account_data(field, type_):
1255 return data('account', field, type_)
1257 def channel_data(field, type_):
1258 return data('channel', field, type_)
1260 category = data('category', 'label', compat_str)
1261 categories = [category] if category else None
1263 nsfw = video.get('nsfw')
1265 age_limit = 18 if nsfw else 0
1269 webpage_url = 'https://%s/videos/watch/%s' % (host, video_id)
1274 'description': description,
1275 'thumbnail': urljoin(webpage_url, video.get('thumbnailPath')),
1276 'timestamp': unified_timestamp(video.get('publishedAt')),
1277 'uploader': account_data('displayName', compat_str),
1278 'uploader_id': str_or_none(account_data('id', int)),
1279 'uploader_url': url_or_none(account_data('url', compat_str)),
1280 'channel': channel_data('displayName', compat_str),
1281 'channel_id': str_or_none(channel_data('id', int)),
1282 'channel_url': url_or_none(channel_data('url', compat_str)),
1283 'language': data('language', 'id', compat_str),
1284 'license': data('licence', 'label', compat_str),
1285 'duration': int_or_none(video.get('duration')),
1286 'view_count': int_or_none(video.get('views')),
1287 'like_count': int_or_none(video.get('likes')),
1288 'dislike_count': int_or_none(video.get('dislikes')),
1289 'age_limit': age_limit,
1290 'tags': try_get(video, lambda x: x['tags'], list),
1291 'categories': categories,
1293 'subtitles': subtitles,
1294 'webpage_url': webpage_url,
1298 class PeerTubePlaylistIE(InfoExtractor):
1299 IE_NAME = 'PeerTube:Playlist'
1302 'c': 'video-channels',
1303 'w/p': 'video-playlists',
1305 _VALID_URL = r'''(?x
)
1306 https?
://(?P
<host
>%s)/(?P
<type>(?
:%s))/
1308 ''' % (PeerTubeIE._INSTANCES_RE, '|'.join(_TYPES.keys()))
1310 'url': 'https://peertube.tux.ovh/w/p/3af94cba-95e8-4b74-b37a-807ab6d82526',
1312 'id': '3af94cba-95e8-4b74-b37a-807ab6d82526',
1313 'description': 'playlist',
1314 'timestamp': 1611171863,
1315 'title': 'playlist',
1317 'playlist_mincount': 6,
1319 'url': 'https://peertube.tux.ovh/w/p/wkyqcQBnsvFxtUB2pkYc1e',
1321 'id': 'wkyqcQBnsvFxtUB2pkYc1e',
1322 'description': 'Cette liste de vidéos contient uniquement les jeux qui peuvent être terminés en une seule vidéo.',
1323 'title': 'Let\'s Play',
1324 'timestamp': 1604147331,
1326 'playlist_mincount': 6,
1328 'url': 'https://peertube.debian.social/w/p/hFdJoTuyhNJVa1cDWd1d12',
1330 'id': 'hFdJoTuyhNJVa1cDWd1d12',
1331 'description': 'Diversas palestras do Richard Stallman no Brasil.',
1332 'title': 'Richard Stallman no Brasil',
1333 'timestamp': 1599676222,
1335 'playlist_mincount': 9,
1337 'url': 'https://peertube2.cpy.re/a/chocobozzz/videos',
1340 'timestamp': 1553874564,
1341 'title': 'chocobozzz',
1343 'playlist_mincount': 2,
1345 'url': 'https://framatube.org/c/bf54d359-cfad-4935-9d45-9d6be93f63e8/videos',
1347 'id': 'bf54d359-cfad-4935-9d45-9d6be93f63e8',
1348 'timestamp': 1519917377,
1349 'title': 'Les vidéos de Framasoft',
1351 'playlist_mincount': 345,
1353 'url': 'https://peertube2.cpy.re/c/blender_open_movies@video.blender.org/videos',
1355 'id': 'blender_open_movies@video.blender.org',
1356 'timestamp': 1542287810,
1357 'title': 'Official Blender Open Movies',
1359 'playlist_mincount': 11,
1361 _API_BASE = 'https://%s/api/v1/%s/%s%s'
1364 def call_api(self, host, name, path, base, **kwargs):
1365 return self._download_json(
1366 self._API_BASE % (host, base, name, path), name, **kwargs)
1368 def fetch_page(self, host, id, type, page):
1370 video_data = self.call_api(
1372 f'/videos?sort=-createdAt&start={self._PAGE_SIZE * (page - 1)}&count={self._PAGE_SIZE}&nsfw=both',
1373 type, note=f'Downloading page {page}').get('data', [])
1374 for video in video_data:
1375 shortUUID = video.get('shortUUID') or try_get(video, lambda x: x['video']['shortUUID'])
1376 video_title = video.get('name') or try_get(video, lambda x: x['video']['name'])
1377 yield self.url_result(
1378 f'https://{host}/w/{shortUUID}', PeerTubeIE.ie_key(),
1379 video_id=shortUUID, video_title=video_title)
1381 def _extract_playlist(self, host, type, id):
1382 info = self.call_api(host, id, '', type, note='Downloading playlist information', fatal=False)
1384 playlist_title = info.get('displayName')
1385 playlist_description = info.get('description')
1386 playlist_timestamp = unified_timestamp(info.get('createdAt'))
1387 channel = try_get(info, lambda x: x['ownerAccount']['name']) or info.get('displayName')
1388 channel_id = try_get(info, lambda x: x['ownerAccount']['id']) or info.get('id')
1389 thumbnail = info.get('thumbnailPath')
1390 thumbnail = f'https://{host}{thumbnail}' if thumbnail else None
1392 entries = OnDemandPagedList(functools.partial(
1393 self.fetch_page, host, id, type), self._PAGE_SIZE)
1395 return self.playlist_result(
1396 entries, id, playlist_title, playlist_description,
1397 timestamp=playlist_timestamp, channel=channel, channel_id=channel_id, thumbnail=thumbnail)
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)