invidious.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. if(!isset($_COOKIE["session"]) || $_COOKIE["session"] != "true") {
  3. http_response_code(403);
  4. die('Forbidden');
  5. }
  6. ?>
  7. <!DOCTYPE html>
  8. <html lang="en" style="height:100%">
  9. <head>
  10. <meta charset="utf-8">
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12. <script src="/assets/js/player/youplay.js"></script>
  13. </head>
  14. <body style="margin:0;height:100%;overflow:hidden">
  15. <video class="video-js vjs-default-skin" controls id="player" style="width:100%;height:100%;display:none">
  16. Your browser does not support the video tag.
  17. </video>
  18. <script>
  19. var itag_info = {
  20. 5:"FLV[400x240]",
  21. 6:"FLV[450x270]",
  22. 17:"3GP[176x144]",
  23. 18:"MP4[640x360]",
  24. 22:"HD MP4[1280x720]",
  25. 34:"FLV[640x360]",
  26. 35:"FLV[854x480]",
  27. 36:"3GP[320x180]",
  28. 37:"MP4[1920x1080]",
  29. 38:"MP4[4096x3072]",
  30. 43:"WEBM[640x360]",
  31. 44:"WEBM[854x480]",
  32. 45:"WEBM[1280x720]",
  33. 46:"WEBM[1920x1080]",
  34. 59:"MP4[854x480]",
  35. 78:"MP4[854x480]",
  36. 137:"(Video Only) MP4[1920x1080]",
  37. 248:"(Video Only) WEBM[1920x1080]",
  38. 136:"(Video Only) MP4[1280x720]",
  39. 247:"(Video Only) WEBM[1280x720]",
  40. 135:"(Video Only) MP4[854x480]",
  41. 244:"(Video Only) WEBM[854x480]",
  42. 134:"(Video Only) MP4[640x360]",
  43. 243:"(Video Only) WEBM[640x360]",
  44. 133:"(Video Only) MP4[320x240]",
  45. 242:"(Video Only) WEBM[320x240]",
  46. 160:"(Video Only) MP4[176x144]",
  47. 278:"(Video Only) WEBM[176x144]",
  48. 140:"(Audio Only) M4A[128Kbps]",
  49. 171:"(Audio Only) WEBM[128Kbps]",
  50. 249:"(Audio Only) WEBM[50Kbps]",
  51. 250:"(Audio Only) WEBM[70Kbps]",
  52. 251:"(Audio Only) WEBM[160Kbps]"
  53. };
  54. var xhr = new XMLHttpRequest();
  55. xhr.open('GET','https://<?=$_GET["server"]?>/api/v1/videos/<?=$_GET["id"]?>');
  56. xhr.onload = function() {
  57. if(xhr.status === 200) {
  58. var data = JSON.parse(xhr.responseText);
  59. document.getElementById("player").setAttribute("title",data.title);
  60. document.getElementById("player").setAttribute("poster",data.videoThumbnails[1].url);
  61. for(var i=0;i<data.captions.length;i++) {
  62. var caption = document.createElement("track");
  63. caption.setAttribute("kind","captions");
  64. caption.setAttribute("label",data.captions[i].label);
  65. caption.src = "https://<?=$_GET["server"]?>"+data.captions[i].url;
  66. document.getElementById("player").appendChild(caption);
  67. }
  68. var streams = new Array;
  69. var audios = new Array;
  70. for(var i=0;i<data.formatStreams.length;i++) {
  71. var stream = new Object();
  72. stream.src = data.formatStreams[i].url.replace(/(https\:\/\/)[^\.]+(\.googlevideo\.com)/,"https://redirector$2");
  73. stream.label = itag_info[data.formatStreams[i].itag];
  74. stream.audio = true;
  75. streams.push(stream);
  76. }
  77. for(var i=0;i<data.adaptiveFormats.length;i++) {
  78. var stream = new Object();
  79. stream.src = data.adaptiveFormats[i].url.replace(/(https\:\/\/)[^\.]+(\.googlevideo\.com)/,"https://redirector$2");
  80. stream.label = itag_info[data.adaptiveFormats[i].itag];
  81. stream.audio = false;
  82. if(stream.label) {
  83. if(stream.label.indexOf("(Audio Only)") != -1) audios.push(stream.src);
  84. else streams.push(stream);
  85. }
  86. }
  87. document.getElementById("player").style.display = "block";
  88. yp_player({share:false,use_desktop_skin:true,sources:streams,audio_url:audios});
  89. }
  90. else document.write("Sorry, there was an error while trying to load your video.");
  91. }
  92. xhr.send();
  93. </script>
  94. </body>
  95. </html>