]>
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
22 class PeerTubeIE(InfoExtractor
):
23 _INSTANCES_RE
= r
'''(?:
24 # Taken from https://instances.joinpeertube.org/instances
31 archive\.vidicon\.org|
41 clap\.nerv-project\.eu|
42 climatejustice\.video|
44 conspiracydistillery\.com|
45 darkvapor\.nohost\.me|
46 daschauher\.aksel\.rocks|
47 digitalcourage\.video|
48 dreiecksnebel\.alex-detsch\.de|
56 fotogramas\.politicaconciencia\.org|
61 grypstube\.uni-greifswald\.de|
70 kirche\.peertube-host\.de|
76 lepetitmayennais\.fr\.nf|
85 lolitube\.freedomchan\.moe|
86 lucarne\.balsamine\.be|
92 media\.inno3\.cricket|
94 media\.krashboyz\.org|
95 media\.over-world\.org|
97 media\.undeadnetwork\.de|
98 medias\.pingbase\.net|
99 melsungen\.peertube-host\.de|
102 monplaisirtube\.ddns\.net|
106 mytube\.kn-cloud\.de|
108 myworkoutarenapeertube\.cf|
109 nanawel-peertube\.dyndns\.org|
113 ovaltube\.codinglab\.ch|
118 peertube1\.zeteo\.me|
121 peertube\.alpharius\.io|
122 peertube\.am-networks\.fr|
123 peertube\.anduin\.net|
124 peertube\.anzui\.dev|
125 peertube\.arbleizez\.bzh|
126 peertube\.art3mis\.de|
127 peertube\.atilla\.org|
128 peertube\.atsuchan\.page|
129 peertube\.aukfood\.net|
130 peertube\.aventer\.biz|
131 peertube\.b38\.rural-it\.org|
132 peertube\.beeldengeluid\.nl|
134 peertube\.bgzashtita\.es|
135 peertube\.bitsandlinux\.com|
137 peertube\.boba\.best|
139 peertube\.bridaahost\.ynh\.fr|
140 peertube\.bubbletea\.dev|
141 peertube\.bubuit\.net|
142 peertube\.cabaal\.net|
143 peertube\.cats-home\.net|
144 peertube\.chemnitz\.freifunk\.net|
145 peertube\.chevro\.fr|
146 peertube\.chrisspiegl\.com|
147 peertube\.chtisurel\.net|
148 peertube\.cipherbliss\.com|
149 peertube\.cloud\.sans\.pub|
150 peertube\.cpge-brizeux\.fr|
151 peertube\.ctseuro\.com|
152 peertube\.cuatrolibertades\.org|
153 peertube\.cybercirujas\.club|
154 peertube\.cythin\.com|
155 peertube\.davigge\.com|
156 peertube\.dc\.pini\.fr|
157 peertube\.debian\.social|
158 peertube\.demonix\.fr|
159 peertube\.designersethiques\.org|
161 peertube\.devloprog\.org|
164 peertube\.ecologie\.bzh|
166 peertube\.european-pirates\.eu|
167 peertube\.euskarabildua\.eus|
168 peertube\.fenarinarsa\.com|
169 peertube\.fomin\.site|
170 peertube\.forsud\.be|
171 peertube\.francoispelletier\.org|
172 peertube\.freenet\.ru|
173 peertube\.freetalklive\.com|
174 peertube\.functional\.cafe|
175 peertube\.gardeludwig\.fr|
176 peertube\.gargantia\.fr|
177 peertube\.gcfamily\.fr|
179 peertube\.get-racing\.de|
180 peertube\.gidikroon\.eu|
181 peertube\.gruezishop\.ch|
182 peertube\.habets\.house|
183 peertube\.hackerfraternity\.org|
184 peertube\.ichigo\.everydayimshuflin\.com|
185 peertube\.ignifi\.me|
186 peertube\.inapurna\.org|
187 peertube\.informaction\.info|
188 peertube\.interhop\.org|
189 peertube\.iselfhost\.com|
191 peertube\.jensdiemer\.de|
192 peertube\.joffreyverd\.fr|
194 peertube\.kathryl\.fr|
195 peertube\.keazilla\.net|
196 peertube\.klaewyss\.fr|
197 peertube\.kodcast\.com|
198 peertube\.kx\.studio|
199 peertube\.lagvoid\.com|
200 peertube\.lavallee\.tech|
201 peertube\.le5emeaxe\.fr|
202 peertube\.lestutosdeprocessus\.fr|
203 peertube\.librenet\.co\.za|
204 peertube\.logilab\.fr|
205 peertube\.louisematic\.site|
206 peertube\.luckow\.org|
208 peertube\.lyceeconnecte\.fr|
209 peertube\.manalejandro\.com|
211 peertube\.mattone\.net|
212 peertube\.maxweiss\.io|
213 peertube\.monlycee\.net|
214 peertube\.mxinfo\.fr|
215 peertube\.myrasp\.eu|
216 peertube\.nebelcloud\.de|
217 peertube\.netzbegruenung\.de|
218 peertube\.newsocial\.tech|
219 peertube\.nicolastissot\.fr|
221 peertube\.offerman\.com|
222 peertube\.opencloud\.lu|
223 peertube\.orthus\.link|
224 peertube\.patapouf\.xyz|
226 peertube\.plataformess\.org|
228 peertube\.portaesgnos\.org|
229 peertube\.r2\.enst\.fr|
231 peertube\.radres\.xyz|
233 peertube\.robonomics\.network|
234 peertube\.rtnkv\.cloud|
235 peertube\.runfox\.tk|
236 peertube\.satoshishop\.de|
237 peertube\.scic-tetris\.org|
238 peertube\.securitymadein\.lu|
239 peertube\.semweb\.pro|
240 peertube\.social\.my-wan\.de|
241 peertube\.soykaf\.org|
242 peertube\.stefofficiel\.me|
246 peertube\.takeko\.cyou|
247 peertube\.tangentfox\.com|
248 peertube\.taxinachtegel\.de|
249 peertube\.thenewoil\.xyz|
250 peertube\.ti-fr\.com|
251 peertube\.tiennot\.net|
252 peertube\.troback\.com|
253 peertube\.tspu\.edu\.ru|
258 peertube\.underworld\.fr|
260 peertube\.ventresmous\.fr|
262 peertube\.w\.utnw\.de|
263 peertube\.westring\.digital|
264 peertube\.xwiki\.com|
265 peertube\.zoz-serv\.org|
267 periscope\.numenaute\.org|
269 petitlutinartube\.fr|
274 player\.ojamajo\.moe|
276 pocketnetpeertube1\.nohost\.me|
277 pocketnetpeertube3\.nohost\.me|
278 pocketnetpeertube4\.nohost\.me|
279 pocketnetpeertube5\.nohost\.me|
280 pocketnetpeertube6\.nohost\.me|
286 ptb\.lunarviews\.net|
287 ptmir1\.inter21\.net|
288 ptmir2\.inter21\.net|
289 ptmir3\.inter21\.net|
290 ptmir4\.inter21\.net|
291 ptmir5\.inter21\.net|
292 ptube\.horsentiers\.fr|
293 ptube\.xmanifesto\.club|
295 re-wizja\.re-medium\.com|
301 sender-fm\.veezee\.tube|
302 serv1\.wiki-tube\.de|
303 serv3\.wiki-tube\.de|
310 stream\.shahab\.nohost\.me|
312 studios\.racer159\.com|
313 testtube\.florimond\.eu|
314 tgi\.hosted\.spacebear\.ee|
317 theater\.ethernia\.net|
324 tube-aix-marseille\.beta\.education\.fr|
325 tube-amiens\.beta\.education\.fr|
326 tube-besancon\.beta\.education\.fr|
327 tube-bordeaux\.beta\.education\.fr|
328 tube-clermont-ferrand\.beta\.education\.fr|
329 tube-corse\.beta\.education\.fr|
330 tube-creteil\.beta\.education\.fr|
331 tube-dijon\.beta\.education\.fr|
332 tube-education\.beta\.education\.fr|
333 tube-grenoble\.beta\.education\.fr|
334 tube-lille\.beta\.education\.fr|
335 tube-limoges\.beta\.education\.fr|
336 tube-montpellier\.beta\.education\.fr|
337 tube-nancy\.beta\.education\.fr|
338 tube-nantes\.beta\.education\.fr|
339 tube-nice\.beta\.education\.fr|
340 tube-normandie\.beta\.education\.fr|
341 tube-orleans-tours\.beta\.education\.fr|
342 tube-outremer\.beta\.education\.fr|
343 tube-paris\.beta\.education\.fr|
344 tube-poitiers\.beta\.education\.fr|
345 tube-reims\.beta\.education\.fr|
346 tube-rennes\.beta\.education\.fr|
347 tube-strasbourg\.beta\.education\.fr|
348 tube-toulouse\.beta\.education\.fr|
349 tube-versailles\.beta\.education\.fr|
350 tube1\.it\.tuwien\.ac\.at|
351 tube\.abolivier\.bzh|
353 tube\.aerztefueraufklaerung\.de|
370 tube\.cloud-libre\.eu|
373 tube\.cryptography\.dog|
374 tube\.darknight-coffee\.org|
377 tube\.dsocialize\.net|
383 tube\.frischesicht\.de|
389 tube\.hackerscop\.org|
392 tube\.kai-stuht\.com|
395 tube\.lacaveatonton\.ovh|
398 tube\.lucie-philou\.com|
399 tube\.melonbread\.xyz|
407 tube\.nuagelibre\.fr|
412 tube\.opportunis\.me|
415 tube\.others\.social|
417 tube\.plomlompom\.com|
419 tube\.portes-imaginaire\.org|
421 tube\.rebellion\.global|
422 tube\.rhythms-of-resistance\.org|
427 tube\.schleuss\.online|
428 tube\.schule\.social|
435 tube\.superseriousbusiness\.org|
441 tube\.troopers\.agency|
442 tube\.tylerdavis\.xyz|
444 tube\.vigilian-consulting\.nl|
457 tuvideo\.encanarias\.info|
464 tv\.generallyrubbish\.net\.au|
466 tv\.mattchristiansenmedia\.com|
467 tv\.netwhood\.online|
470 tv\.pirateradio\.social|
473 twctube\.twc-zone\.eu|
487 vid\.pravdastalina\.info|
489 vid\.rajeshtaylor\.com|
490 vid\.samtripoli\.com|
495 video\.1146\.nohost\.me|
496 video\.altertek\.org|
497 video\.anartist\.org|
498 video\.apps\.thedoodleproject\.net|
500 video\.asgardius\.company|
501 video\.balsillie\.net|
502 video\.bards\.online|
503 video\.binarydad\.com|
504 video\.blast-info\.fr|
506 video\.cigliola\.com|
507 video\.cm-en-transition\.fr|
510 video\.codingfield\.com|
511 video\.comptoir\.net|
512 video\.comune\.trento\.it|
516 video\.demokratischer-sommer\.de|
517 video\.discord-insoumis\.fr|
518 video\.dolphincastle\.com|
519 video\.dresden\.network|
520 video\.ecole-89\.com|
521 video\.elgrillolibertario\.org|
522 video\.emergeheart\.info|
523 video\.eradicatinglove\.xyz|
524 video\.ethantheenigma\.me|
525 video\.exodus-privacy\.eu\.org|
528 video\.greenmycity\.eu|
529 video\.guerredeclasse\.fr|
531 video\.hackers\.town|
532 video\.hardlimit\.com|
535 video\.internet-czas-dzialac\.pl|
536 video\.islameye\.com|
538 video\.kuba-orlik\.name|
539 video\.kyushojitsu\.ca|
541 video\.lespoesiesdheloise\.fr|
544 video\.linc\.systems|
546 video\.linuxtrent\.it|
547 video\.lokal\.social|
551 video\.marcorennmaus\.de|
552 video\.mass-trespass\.uk|
554 video\.mundodesconocido\.com|
557 video\.odayacres\.farm|
558 video\.ozgurkon\.org|
559 video\.p1ng0ut\.social|
562 video\.pony\.gallery|
563 video\.potate\.space|
564 video\.pourpenser\.pro|
565 video\.progressiv\.dev|
566 video\.resolutions\.it|
568 video\.screamer\.wiki|
569 video\.sdm-tools\.net|
571 video\.shitposter\.club|
574 video\.stuartbrand\.co\.uk|
575 video\.thinkof\.name|
579 video\.vaku\.org\.ua|
581 video\.violoncello\.ch|
583 video\.wsf2021\.info|
585 videos-passages\.huma-num\.fr|
586 videos\.3d-wolf\.com|
587 videos\.ahp-numerique\.fr|
588 videos\.alexandrebadalo\.pt|
589 videos\.archigny\.net|
590 videos\.benjaminbrady\.ie|
591 videos\.buceoluegoexisto\.com|
593 videos\.casually\.cat|
594 videos\.cloudron\.io|
595 videos\.coletivos\.org|
596 videos\.danksquad\.org|
597 videos\.denshi\.live|
598 videos\.fromouter\.space|
600 videos\.globenet\.org|
603 videos\.john-livingston\.fr|
604 videos\.jordanwarne\.xyz|
605 videos\.lavoixdessansvoix\.org|
606 videos\.leslionsfloorball\.fr|
608 videos\.martyn\.berlin|
609 videos\.mastodont\.cat|
610 videos\.monstro1\.com|
612 videos\.optoutpod\.com|
613 videos\.petch\.rocks|
614 videos\.pzelawski\.xyz|
616 videos\.scanlines\.xyz|
619 videos\.stadtfabrikanten\.org|
620 videos\.tankernn\.eu|
621 videos\.testimonia\.org|
622 videos\.thisishowidontdisappear\.com|
623 videos\.traumaheilung\.net|
625 videos\.wakkerewereld\.nu|
633 vulgarisation-informatique\.fr|
634 watch\.breadtube\.tv|
635 watch\.deranalyst\.ch|
636 watch\.ignorance\.eu|
638 watch\.libertaria\.space|
640 watch\.softinio\.com|
641 watch\.tubelab\.video|
643 webtv\.vandoeuvre\.net|
649 www4\.mir\.inter21\.net|
650 www\.birkeundnymphe\.de|
651 www\.captain-german\.com|
653 xxivproduction\.video|
657 peertube\.rainbowswingers\.net|
661 videomensoif\.ynh\.fr|
662 peertube\.travelpandas\.eu|
663 peertube\.rachetjay\.fr|
664 peertube\.montecsys\.fr|
667 peertube\.umeahackerspace\.se|
669 video\.monsieurbidouille\.fr|
670 tube\.openalgeria\.org|
672 video\.anormallostpod\.ovh|
673 tube\.crapaud-fou\.org|
677 peertube\.snargol\.com|
682 peertube\.osureplayviewer\.xyz|
683 peertube\.mathieufamily\.ovh|
684 www\.videos-libr\.es|
686 peertube\.fediverse\.ru|
687 peertube\.oiseauroch\.fr|
695 peertube\.chantierlibre\.org|
701 videos\.elbinario\.net|
707 peertube\.gnumeria\.eu\.org|
711 tube\.kalah-france\.org|
715 peertube\.hatthieves\.es|
716 video\.fitchfamily\.org|
720 tube\.22decembre\.eu|
721 peertube\.harmoniescreatives\.com|
723 video\.thedwyers\.co|
724 video\.bruitbruit\.com|
725 peertube\.foxfam\.club|
727 videos\.bugs\.social|
728 peertube\.malbert\.xyz|
729 peertube\.bilange\.ca|
732 peertube\.fedilab\.app|
734 video\.mstddntfdn\.online|
736 peertube\.sl-network\.fr|
737 peertube\.dynlinux\.io|
738 peertube\.david\.durieux\.family|
739 peertube\.linuxrocks\.online|
741 v\.kretschmann\.social|
744 tube\.dragonpsi\.xyz|
745 peertube\.boneheadmedia\.com|
746 videos\.funkwhale\.audio|
748 peertube\.gcaillaut\.fr|
755 peertube\.simounet\.net|
759 peertube\.kerenon\.com|
761 tube\.calculate\.social|
762 peertube\.mckillop\.org|
763 tube\.netzspielplatz\.de|
767 peertube\.stephenson\.cc|
769 peertube\.kajalinifi\.de|
772 peertube\.ffs2play\.fr|
773 peertube\.leboulaire\.ovh|
774 peertube\.tronic-studio\.com|
775 peertube\.public\.cat|
776 peertube\.metalbanana\.net|
778 peertube\.alter-nativ-voll\.de|
780 tube\.worldofhauru\.xyz|
782 peertube\.teleassist\.fr|
785 media\.privacyinternational\.org|
787 video\.halle-leaks\.de|
788 video\.grosskopfgames\.de|
789 peertube\.schaeferit\.de|
790 peertube\.jackbot\.fr|
791 tube\.extinctionrebellion\.fr|
795 peertube\.zergy\.net|
796 peertube\.roflcopter\.fr|
797 peertube\.floss-marketing-school\.com|
799 peertube\.iriseden\.eu|
800 videos\.ubuntu-paris\.org|
801 peertube\.mastodon\.host|
803 peertube\.s2s\.video|
808 peertube\.normandie-libre\.fr|
810 video\.lacaveatonton\.ovh|
812 peertube\.servebeer\.com|
813 peertube\.fedi\.quebec|
818 tube\.unmondemeilleur\.eu|
825 video\.devinberg\.com|
827 peertube\.kosebamse\.com|
828 yunopeertube\.myddns\.me|
829 peertube\.varney\.fr|
830 peertube\.anon-kenkai\.com|
833 videos\.dinofly\.com|
837 video\.heromuster\.com|
838 video\.lemediatv\.fr|
843 pt\.laurentkruger\.fr|
844 video\.monarch-pass\.net|
845 peertube\.artica\.center|
846 video\.alternanet\.fr|
848 fanvid\.stopthatimp\.net|
853 peertube\.mablr\.org|
857 devtube\.dev-wiki\.de|
858 raptube\.antipub\.org|
860 peertube\.mygaia\.org|
862 peertube\.livingutopia\.org|
863 peertube\.the-penguin\.de|
864 tube\.thechangebook\.org|
868 mplayer\.demouliere\.eu|
871 peertube\.zapashcanon\.fr|
872 video\.latavernedejohnjohn\.fr|
873 peertube\.pcservice46\.fr|
874 peertube\.mazzonetto\.eu|
875 video\.irem\.univ-paris-diderot\.fr|
876 video\.livecchi\.cloud|
879 video\.cabane-libre\.org|
880 peertube\.openstreetmap\.fr|
881 videos\.alolise\.org|
887 peertube\.freeforge\.eu|
888 video\.arbitrarion\.com|
889 video\.datsemultimedia\.com|
891 peertube\.ricostrongxxx\.com|
892 docker\.videos\.lecygnenoir\.info|
893 peertube\.togart\.de|
894 tube\.postblue\.info|
895 videos\.domainepublic\.net|
896 peertube\.cyber-tribal\.com|
897 video\.gresille\.org|
898 peertube\.dsmouse\.net|
899 cinema\.yunohost\.support|
900 tube\.theocevaer\.fr|
904 peertube\.metawurst\.space|
907 video\.freeradical\.zone|
910 pt\.kircheneuenburg\.de|
913 videos\.side-ways\.net|
916 video\.taboulisme\.com|
920 video\.monsieur-a\.fr|
921 peertube\.librelois\.fr|
922 videos\.pair2jeux\.tube|
923 videos\.pueseso\.club|
924 peer\.mathdacloud\.ovh|
925 media\.assassinate-you\.net|
927 ptube\.rousset\.nom\.fr|
931 peertube\.makotoworkshop\.org|
932 peertube\.serveur\.slv-valbonne\.fr|
937 pire\.artisanlogiciel\.net|
938 videos\.numerique-en-commun\.fr|
940 video\.die-partei\.social|
942 peertube\.swarm\.solvingmaz\.es|
943 tube\.pericoloso\.ovh|
944 watching\.cypherpunk\.observer|
945 videos\.adhocmusic\.com|
947 peertube\.librelabucm\.org|
948 videos\.numericoop\.fr|
949 peertube\.koehn\.com|
950 peertube\.anarchmusicall\.net|
951 tube\.kampftoast\.de|
953 peertube\.xtenz\.xyz|
956 peertube\.nomagic\.uk|
958 videos\.koumoul\.com|
959 video\.rastapuls\.com|
960 video\.mantlepro\.com|
961 video\.deadsuperhero\.com|
962 peertube\.musicstudio\.pro|
963 peertube\.we-keys\.fr|
964 artitube\.artifaille\.fr|
965 peertube\.ethernia\.net|
969 peertube\.donnadieu\.fr|
970 argos\.aquilenet\.fr|
973 videos\.darckoune\.moe|
974 tube\.traydent\.info|
975 dev\.videos\.lecygnenoir\.info|
976 peertube\.nayya\.org|
978 peertube\.mofgao\.space|
979 video\.lequerrec\.eu|
980 peertube\.amicale\.net|
989 peertube\.heberge\.fr|
991 videos\.cloudfrancois\.fr|
1000 videos\.lescommuns\.org|
1004 peertube\.nogafa\.org|
1005 megatube\.lilomoino\.fr|
1006 peertube\.tamanoir\.foucry\.net|
1007 peertube\.devosi\.org|
1008 peertube\.1312\.media|
1009 tube\.bootlicker\.party|
1011 video\.blueline\.mg|
1012 tube\.homecomputing\.fr|
1013 tube\.ouahpiti\.info|
1014 video\.tedomum\.net|
1017 peertube\.gaialabs\.ch|
1020 video\.migennes\.net|
1023 videos\.iut-orsay\.fr|
1024 peertube\.solidev\.net|
1026 video\.passageenseine\.fr|
1027 videos\.festivalparminous\.org|
1028 peertube\.touhoppai\.moe|
1030 peer\.hostux\.social|
1032 peertube\.walkingmountains\.fr|
1034 peertube\.parleur\.net|
1035 peertube\.heraut\.eu|
1036 tube\.aquilenet\.fr|
1037 peertube\.gegeweb\.eu|
1040 tube\.conferences-gesticulees\.net|
1041 peertube\.datagueule\.tv|
1043 tube\.mochi\.academy|
1045 video\.colibris-outilslibres\.org|
1054 _UUID_RE
= r
'[\da-zA-Z]{22}|[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}'
1055 _API_BASE
= 'https://%s/api/v1/videos/%s/%s'
1056 _VALID_URL
= r
'''(?x)
1058 peertube:(?P<host>[^:]+):|
1059 https?://(?P<host_2>%s)/(?:videos/(?:watch|embed)|api/v\d/videos|w)/
1062 ''' % (_INSTANCES_RE
, _UUID_RE
)
1064 'url': 'https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d',
1065 'md5': '8563064d245a4be5705bddb22bb00a28',
1067 'id': '9c9de5e8-0a1e-484a-b099-e80766180a6d',
1069 'title': 'What is PeerTube?',
1070 'description': 'md5:3fefb8dde2b189186ce0719fda6f7b10',
1071 'thumbnail': r
're:https?://.*\.(?:jpg|png)',
1072 'timestamp': 1538391166,
1073 'upload_date': '20181001',
1074 'uploader': 'Framasoft',
1076 'uploader_url': 'https://framatube.org/accounts/framasoft',
1077 'channel': 'A propos de PeerTube',
1078 'channel_id': '2215',
1079 'channel_url': 'https://framatube.org/video-channels/joinpeertube',
1081 'license': 'Attribution - Share Alike',
1085 'dislike_count': int,
1086 'tags': ['framasoft', 'peertube'],
1087 'categories': ['Science & Technology'],
1090 'url': 'https://peertube2.cpy.re/w/122d093a-1ede-43bd-bd34-59d2931ffc5e',
1092 'id': '122d093a-1ede-43bd-bd34-59d2931ffc5e',
1094 'title': 'E2E tests',
1095 'uploader_id': '37855',
1096 'timestamp': 1589276219,
1097 'upload_date': '20200512',
1098 'uploader': 'chocobozzz',
1101 'url': 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',
1103 'id': '3fbif9S3WmtTP8gGsC5HBd',
1105 'title': 'E2E tests',
1106 'uploader_id': '37855',
1107 'timestamp': 1589276219,
1108 'upload_date': '20200512',
1109 'uploader': 'chocobozzz',
1112 'url': 'https://peertube2.cpy.re/api/v1/videos/3fbif9S3WmtTP8gGsC5HBd',
1114 'id': '3fbif9S3WmtTP8gGsC5HBd',
1116 'title': 'E2E tests',
1117 'uploader_id': '37855',
1118 'timestamp': 1589276219,
1119 'upload_date': '20200512',
1120 'uploader': 'chocobozzz',
1124 'url': 'peertube:spacepub.space:d8943b2d-8280-497b-85ec-bc282ec2afdc',
1126 'id': 'd8943b2d-8280-497b-85ec-bc282ec2afdc',
1128 'title': 'Dot matrix printer shell demo',
1130 'timestamp': 1587401293,
1131 'upload_date': '20200420',
1132 'uploader': 'Drew DeVault',
1135 'url': 'https://peertube.debian.social/videos/watch/0b04f13d-1e18-4f1d-814e-4979aa7c9c44',
1136 'only_matching': True,
1139 'url': 'https://vod.ksite.de/videos/watch/9bb88cd3-9959-46d9-9ab9-33d2bb704c39',
1140 'only_matching': True,
1142 'url': 'https://vod.ksite.de/videos/embed/fed67262-6edb-4d1c-833b-daa9085c71d7',
1143 'only_matching': True,
1145 'url': 'https://peertube.tv/api/v1/videos/c1875674-97d0-4c94-a058-3f7e64c962e8',
1146 'only_matching': True,
1148 'url': 'peertube:framatube.org:b37a5b9f-e6b5-415c-b700-04a5cd6ec205',
1149 'only_matching': True,
1153 def _extract_peertube_url(webpage
, source_url
):
1155 r
'https?://(?P<host>[^/]+)/(?:videos/(?:watch|embed)|w)/(?P<id>%s)'
1156 % PeerTubeIE
._UUID
_RE
, source_url
)
1157 if mobj
and any(p
in webpage
for p
in (
1158 'meta property="og:platform" content="PeerTube"',
1160 'There will be other non JS-based clients to access PeerTube',
1161 '>We are sorry but it seems that PeerTube is not compatible with your web browser.<')):
1162 return 'peertube:%s:%s' % mobj
.group('host', 'id')
1165 def _extract_urls(webpage
, source_url
):
1166 entries
= re
.findall(
1167 r
'''(?x)<iframe[^>]+\bsrc=["\'](?P
<url
>(?
:https?
:)?
//%s/videos
/embed
/%s)'''
1168 % (PeerTubeIE._INSTANCES_RE, PeerTubeIE._UUID_RE), webpage)
1170 peertube_url = PeerTubeIE._extract_peertube_url(webpage, source_url)
1172 entries = [peertube_url]
1175 def _call_api(self, host, video_id, path, note=None, errnote=None, fatal=True):
1176 return self._download_json(
1177 self._API_BASE % (host, video_id, path), video_id,
1178 note=note, errnote=errnote, fatal=fatal)
1180 def _get_subtitles(self, host, video_id):
1181 captions = self._call_api(
1182 host, video_id, 'captions', note='Downloading captions JSON',
1184 if not isinstance(captions, dict):
1186 data = captions.get('data')
1187 if not isinstance(data, list):
1191 language_id = try_get(e, lambda x: x['language']['id'], compat_str)
1192 caption_url = urljoin('https://%s' % host, e.get('captionPath'))
1195 subtitles.setdefault(language_id or 'en', []).append({
1200 def _real_extract(self, url):
1201 mobj = self._match_valid_url(url)
1202 host = mobj.group('host') or mobj.group('host_2')
1203 video_id = mobj.group('id')
1205 video = self._call_api(
1206 host, video_id, '', note='Downloading video JSON')
1208 title = video['name']
1211 files = video.get('files') or []
1212 for playlist in (video.get('streamingPlaylists') or []):
1213 if not isinstance(playlist, dict):
1215 playlist_files = playlist.get('files')
1216 if not (playlist_files and isinstance(playlist_files, list)):
1218 files.extend(playlist_files)
1220 if not isinstance(file_, dict):
1222 file_url = url_or_none(file_.get('fileUrl'))
1225 file_size = int_or_none(file_.get('size'))
1226 format_id = try_get(
1227 file_, lambda x: x['resolution']['label'], compat_str)
1228 f = parse_resolution(format_id)
1231 'format_id': format_id,
1232 'filesize': file_size,
1234 if format_id == '0p':
1235 f['vcodec'] = 'none'
1237 f['fps'] = int_or_none(file_.get('fps'))
1239 self._sort_formats(formats)
1241 description = video.get('description')
1242 if description and len(description) >= 250:
1243 # description is shortened
1244 full_description = self._call_api(
1245 host, video_id, 'description', note='Downloading description JSON',
1248 if isinstance(full_description, dict):
1249 description = str_or_none(full_description.get('description')) or description
1251 subtitles = self.extract_subtitles(host, video_id)
1253 def data(section, field, type_):
1254 return try_get(video, lambda x: x[section][field], type_)
1256 def account_data(field, type_):
1257 return data('account', field, type_)
1259 def channel_data(field, type_):
1260 return data('channel', field, type_)
1262 category = data('category', 'label', compat_str)
1263 categories = [category] if category else None
1265 nsfw = video.get('nsfw')
1267 age_limit = 18 if nsfw else 0
1271 webpage_url = 'https://%s/videos/watch/%s' % (host, video_id)
1276 'description': description,
1277 'thumbnail': urljoin(webpage_url, video.get('thumbnailPath')),
1278 'timestamp': unified_timestamp(video.get('publishedAt')),
1279 'uploader': account_data('displayName', compat_str),
1280 'uploader_id': str_or_none(account_data('id', int)),
1281 'uploader_url': url_or_none(account_data('url', compat_str)),
1282 'channel': channel_data('displayName', compat_str),
1283 'channel_id': str_or_none(channel_data('id', int)),
1284 'channel_url': url_or_none(channel_data('url', compat_str)),
1285 'language': data('language', 'id', compat_str),
1286 'license': data('licence', 'label', compat_str),
1287 'duration': int_or_none(video.get('duration')),
1288 'view_count': int_or_none(video.get('views')),
1289 'like_count': int_or_none(video.get('likes')),
1290 'dislike_count': int_or_none(video.get('dislikes')),
1291 'age_limit': age_limit,
1292 'tags': try_get(video, lambda x: x['tags'], list),
1293 'categories': categories,
1295 'subtitles': subtitles,
1296 'webpage_url': webpage_url,
1300 class PeerTubePlaylistIE(InfoExtractor):
1301 IE_NAME = 'PeerTube:Playlist'
1304 'c': 'video-channels',
1305 'w/p': 'video-playlists',
1307 _VALID_URL = r'''(?x
)
1308 https?
://(?P
<host
>%s)/(?P
<type>(?
:%s))/
1310 ''' % (PeerTubeIE._INSTANCES_RE, '|'.join(_TYPES.keys()))
1312 'url': 'https://peertube.tux.ovh/w/p/3af94cba-95e8-4b74-b37a-807ab6d82526',
1314 'id': '3af94cba-95e8-4b74-b37a-807ab6d82526',
1315 'description': 'playlist',
1316 'timestamp': 1611171863,
1317 'title': 'playlist',
1319 'playlist_mincount': 6,
1321 'url': 'https://peertube.tux.ovh/w/p/wkyqcQBnsvFxtUB2pkYc1e',
1323 'id': 'wkyqcQBnsvFxtUB2pkYc1e',
1324 'description': 'Cette liste de vidéos contient uniquement les jeux qui peuvent être terminés en une seule vidéo.',
1325 'title': 'Let\'s Play',
1326 'timestamp': 1604147331,
1328 'playlist_mincount': 6,
1330 'url': 'https://peertube.debian.social/w/p/hFdJoTuyhNJVa1cDWd1d12',
1332 'id': 'hFdJoTuyhNJVa1cDWd1d12',
1333 'description': 'Diversas palestras do Richard Stallman no Brasil.',
1334 'title': 'Richard Stallman no Brasil',
1335 'timestamp': 1599676222,
1337 'playlist_mincount': 9,
1339 'url': 'https://peertube2.cpy.re/a/chocobozzz/videos',
1342 'timestamp': 1553874564,
1343 'title': 'chocobozzz',
1345 'playlist_mincount': 2,
1347 'url': 'https://framatube.org/c/bf54d359-cfad-4935-9d45-9d6be93f63e8/videos',
1349 'id': 'bf54d359-cfad-4935-9d45-9d6be93f63e8',
1350 'timestamp': 1519917377,
1351 'title': 'Les vidéos de Framasoft',
1353 'playlist_mincount': 345,
1355 'url': 'https://peertube2.cpy.re/c/blender_open_movies@video.blender.org/videos',
1357 'id': 'blender_open_movies@video.blender.org',
1358 'timestamp': 1542287810,
1359 'title': 'Official Blender Open Movies',
1361 'playlist_mincount': 11,
1363 _API_BASE = 'https://%s/api/v1/%s/%s%s'
1366 def call_api(self, host, name, path, base, **kwargs):
1367 return self._download_json(
1368 self._API_BASE % (host, base, name, path), name, **kwargs)
1370 def fetch_page(self, host, id, type, page):
1372 video_data = self.call_api(
1374 f'/videos?sort=-createdAt&start={self._PAGE_SIZE * (page - 1)}&count={self._PAGE_SIZE}&nsfw=both',
1375 type, note=f'Downloading page {page}').get('data', [])
1376 for video in video_data:
1377 shortUUID = video.get('shortUUID') or try_get(video, lambda x: x['video']['shortUUID'])
1378 video_title = video.get('name') or try_get(video, lambda x: x['video']['name'])
1379 yield self.url_result(
1380 f'https://{host}/w/{shortUUID}', PeerTubeIE.ie_key(),
1381 video_id=shortUUID, video_title=video_title)
1383 def _extract_playlist(self, host, type, id):
1384 info = self.call_api(host, id, '', type, note='Downloading playlist information', fatal=False)
1386 playlist_title = info.get('displayName')
1387 playlist_description = info.get('description')
1388 playlist_timestamp = unified_timestamp(info.get('createdAt'))
1389 channel = try_get(info, lambda x: x['ownerAccount']['name']) or info.get('displayName')
1390 channel_id = try_get(info, lambda x: x['ownerAccount']['id']) or info.get('id')
1391 thumbnail = format_field(info, 'thumbnailPath', f'https://{host}%s')
1393 entries = OnDemandPagedList(functools.partial(
1394 self.fetch_page, host, id, type), self._PAGE_SIZE)
1396 return self.playlist_result(
1397 entries, id, playlist_title, playlist_description,
1398 timestamp=playlist_timestamp, channel=channel, channel_id=channel_id, thumbnail=thumbnail)
1400 def _real_extract(self, url):
1401 type, host, id = self._match_valid_url(url).group('type', 'host', 'id')
1402 type = self._TYPES[type]
1403 return self._extract_playlist(host, type, id)