youplay.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. $config = parse_ini_file('../config/config.ini',true);
  3. if(!isset($_COOKIE["session"]) || $_COOKIE["session"] != "true" || !$config["Media"]["youplay"]) {
  4. http_response_code(403);
  5. die('Forbidden');
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <html lang="en" style="height:100%">
  10. <head>
  11. <meta charset="utf-8">
  12. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  13. <script src="/assets/js/player/youplay.js"></script>
  14. </head>
  15. <body style="margin:0;height:100%;overflow:hidden">
  16. <?php
  17. include("ytclass.php");
  18. $ytclass = new YTDownloader();
  19. $vdata = $ytclass->getDownloadLinks(htmlspecialchars($_GET["id"]));
  20. if($vdata && is_array($vdata)) {
  21. $vlink = $vdata["dl"];
  22. ?>
  23. <video class="video-js vjs-default-skin" controls id="player" poster="image.php?url=<?=urlencode($vdata["info"]["Thumbnail"])?>" title="<?=htmlspecialchars($vdata["info"]["Title"])?>" style="width:100%;height:100%">
  24. <?php
  25. for($i=0;$i<count($vdata["info"]["Captions"]);$i++) {
  26. echo "<track kind='captions' label='".$vdata["info"]["Captions"][$i]["title"]."' src='ytcaption.php?lang=".$vdata["info"]["Captions"][$i]["lang"]."&url=".urlencode($vdata["info"]["Captions"][$i]["url"])."'>";
  27. }
  28. ?>
  29. Your browser does not support the video tag.
  30. </video>
  31. <script>
  32. yp_player({share:false,use_desktop_skin:true,sources:[
  33. <?php
  34. $formats = array();
  35. for($i=0;$i<count($vlink);$i++) {
  36. if(!strstr($vlink[$i]["type"]," Only)")) {
  37. array_push($formats,$vlink[$i]["type"]);
  38. echo "{src:'".$vlink[$i]["url"]."',label:'".$vlink[$i]["type"]."',audio:true},";
  39. }
  40. else if(strstr($vlink[$i]["type"],"(Video Only)") && !in_array(substr($vlink[$i]["type"],13),$formats)) echo "{src:'".$vlink[$i]["url"]."',label:'".substr($vlink[$i]["type"],13)."',audio:false},";
  41. }
  42. ?>
  43. ],audio_url:[
  44. <?php
  45. for($i=0;$i<count($vlink);$i++) {
  46. if(strstr($vlink[$i]["type"],"(Audio Only)")) echo "'".$vlink[$i]["url"]."',";
  47. }
  48. ?>
  49. ],thumbnails:JSON.parse('<?=json_encode($vdata["info"]["Thumbs"])?>')});
  50. </script>
  51. <?php
  52. }
  53. else if($vdata && !is_array($vdata)) echo "<script>window.location.href='invidious.php?server=".urlencode($vdata)."&id=".urlencode($_GET["id"])."'</script>";
  54. else {
  55. ?>
  56. Sorry, there was an error while trying to load your video.
  57. <?php } ?>
  58. </body>
  59. </html>