Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.50 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3. $results = Array();
  4. $movies = Array();
  5.  
  6. #Display Custom Image
  7. if ($customImageEnabled == "Yes") {
  8.   $title = "<br /><p style='font-size: 55px; -webkit-text-stroke: 2px yellow;'> &nbsp; </p>";
  9.   $display = "<img src='$customImage' style='width: 100%'>";
  10.   $info = "<p style='font-size: 25px;'> &nbsp; </p>";
  11. } else {
  12.  
  13.   #Plex Module
  14.  $url     = 'http://'.$plexServer.':32400/status/sessions?X-Plex-Token='.$plexToken.'';
  15.   $getxml  = file_get_contents($url);
  16.   $xml   = simplexml_load_string($getxml) or die("feed not loading");
  17.   $title   = NULL;
  18.   $display = NULL;
  19.   $info    = NULL;
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.    
  27.  
  28.  
  29.   if ($xml['size'] != '0') {
  30.       foreach ($xml->Video as $clients) {
  31.           if(strstr($clients->Player['address'], $plexClient)) {
  32.                    
  33.             if(strstr($clients['type'], "movie")) {
  34.                 $art = $clients['thumb'];
  35.                 $poster = explode("/", $art);
  36.                 $poster = trim($poster[count($poster) - 1], '/');
  37.                 $filename = '/cache/' . $poster;
  38.                 $dur = $clients['duration'];
  39.                 $durint = (int)$dur;
  40.                 $time = $durint / 1000;
  41.                 $days = floor($time / (24*60*60));
  42.                 $hours = floor(($time - ($days*24*60*60)) / (60*60));
  43.                 $minutes = floor(($time - ($days*24*60*60)-($hours*60*60)) / 60);
  44.                 $seconds = ($time - ($days*24*60*60) - ($hours*60*60) - ($minutes*60)) % 60;
  45.                 $playtime = sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds);
  46.                
  47.                
  48.                 $off = $clients['viewOffset'];
  49.                 $offint = (int)$off;
  50.                 $timeoff = $offint / 1000;
  51.                 $daysoff = floor($timeoff / (24*60*60));
  52.                 $hoursoff = floor(($timeoff - ($daysoff*24*60*60)) / (60*60));
  53.                 $minutesoff = floor(($timeoff - ($daysoff*24*60*60)-($hoursoff*60*60)) / 60);
  54.                 $secondsoff = ($timeoff - ($daysoff*24*60*60) - ($hoursoff*60*60) - ($minutesoff*60)) % 60;
  55.                 $offset = sprintf("%02d:%02d:%02d",$hoursoff,$minutesoff,$secondsoff);
  56.                 if (file_exists($filename)) {
  57.                     #Future Code Coming
  58.                } else {
  59.                     file_put_contents("cache/$poster", fopen("http://$plexServer:32400$art?X-Plex-Token=$plexToken", 'r'));
  60.                 }
  61.  
  62.                 $title = "<br /><p style='font-size: 55px; -webkit-text-stroke: 2px yellow;'> $nowShowingTopText </p>";
  63.                 $display = "<style>
  64.                
  65. .container {
  66. position: relative;
  67. text-align: center;
  68. color: yellow;
  69. font-size: 200%;
  70. width: 100%;
  71. padding-left: 0;
  72. padding-right: 0;
  73. }
  74. .bottom-left {
  75. position: absolute;
  76. bottom: 8px;
  77. left: 16px;
  78. }
  79. .myimg {
  80.  
  81.    width: inherit;
  82.  
  83. }
  84. </style>
  85. <div class='container'>
  86. <img src='cache/$poster' width='100%' height='80%'>
  87. <div class='bottom-left'>$offset/$playtime</div>
  88. </div>";
  89.                 $info = "<p style='font-size: 15px;'>" . $clients['summary'] . "</p>";
  90.        
  91.         }
  92.  
  93.             if(strstr($clients['type'], "episode")) {
  94.                 $art = $clients['grandparentThumb'];
  95.  
  96.                 $poster = explode("/", $art);
  97.                 $poster = trim($poster[count($poster) - 1], '/');
  98.                 $filename = '/cache/' . $poster;
  99.  
  100.                 if (file_exists($filename)) {
  101.                     #Future Code Coming
  102.                } else {
  103.                     file_put_contents("cache/$poster", fopen("http://$plexServer:32400$art?X-Plex-Token=$plexToken", 'r'));
  104.                 }
  105.                 $dur = $clients['duration'];
  106.                 $durint = (int)$dur;
  107.                 $time = $durint / 1000;
  108.                 $days = floor($time / (24*60*60));
  109.                 $hours = floor(($time - ($days*24*60*60)) / (60*60));
  110.                 $minutes = floor(($time - ($days*24*60*60)-($hours*60*60)) / 60);
  111.                 $seconds = ($time - ($days*24*60*60) - ($hours*60*60) - ($minutes*60)) % 60;
  112.                 $playtime = sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds);
  113.                
  114.                
  115.                 $off = $clients['viewOffset'];
  116.                 $offint = (int)$off;
  117.                 $timeoff = $offint / 1000;
  118.                 $daysoff = floor($timeoff / (24*60*60));
  119.                 $hoursoff = floor(($timeoff - ($daysoff*24*60*60)) / (60*60));
  120.                 $minutesoff = floor(($timeoff - ($daysoff*24*60*60)-($hoursoff*60*60)) / 60);
  121.                 $secondsoff = ($timeoff - ($daysoff*24*60*60) - ($hoursoff*60*60) - ($minutesoff*60)) % 60;
  122.                 $offset = sprintf("%02d:%02d:%02d",$hoursoff,$minutesoff,$secondsoff);
  123.                
  124.  
  125.                 $title = "<br /><p style='font-size: 55px; -webkit-text-stroke: 2px yellow;'> $nowShowingTopText </p>";
  126.                 $display = "<style>
  127.                
  128. .container {
  129. position: relative;
  130. text-align: center;
  131. color: yellow;
  132. font-size: 200%;
  133. width: 100%;
  134. padding-left: 0;
  135. padding-right: 0;
  136. }
  137. .bottom-left {
  138. position: absolute;
  139. bottom: 8px;
  140. }
  141. </style>
  142. <div class='container'>
  143. <img src='cache/$poster' height='80%' width='100%'>
  144. <div class='bottom-left'>$offset/$playtime</div>
  145. </div>";
  146.                 $info = "<p style='font-size: 15px;'>" . $clients['parentTitle'] . " Episode: " . $clients['index'] . " - " . $clients['title'] . " - " . $clients['summary'] . "</p>";
  147.            }
  148.         }
  149.      }
  150.   }
  151.  
  152.   #If Nothing is Playing
  153.  if ($display == NULL) {
  154.     $title = "<br /><p style='font-size: 55px; -webkit-text-stroke: 2px yellow;'> $comingSoonTopText </p>";
  155.    
  156.     $UnWatchedMoviesURL = 'http://'.$plexServer.':32400/library/sections/'.$plexServerMovieSection.'/unwatched?X-Plex-Token='.$plexToken.'';
  157.     $getMovies  = file_get_contents($UnWatchedMoviesURL);
  158.     $xmlMovies = simplexml_load_string($getMovies) or die("feed not loading");
  159.     $countMovies = count($xmlMovies);
  160.  
  161.     if ($countMovies > '0') {
  162.       foreach ($xmlMovies->Video as $movie) {
  163.         $movies[] = strip_tags($movie['title']);
  164.       }
  165.      
  166.  
  167.       $random_keys = array_rand($movies,1);
  168.       $showMovie = $movies[$random_keys];
  169.  
  170.       foreach ($xmlMovies->Video as $movie) {
  171.          if(strstr($movie['title'], $showMovie)) {
  172.            $art = $movie['thumb'];
  173.            $poster = explode("/", $art);
  174.            $poster = trim($poster[count($poster) - 1], '/');
  175.            $filename = 'cache/' . $poster;
  176.            if (file_exists($filename)) {
  177.               #Future Code Coming
  178.           } else {
  179.               file_put_contents("cache/$poster", fopen("http://$plexServer:32400$art?X-Plex-Token=$plexToken", 'r'));
  180.            }
  181.  
  182.            $display = "<img src='cache/$poster' width='100%' height='80%'>";
  183.          }
  184.       }
  185.     }
  186.  
  187.     $info = "<br /><p style='font-size: 40px; -webkit-text-stroke: 2px yellow;'> $comingSoonBottomText </p>";
  188.    
  189.   }
  190. }
  191.  
  192. $results['top'] = $title;
  193. $results['middle'] = $display;
  194. $results['bottom'] = $info;
  195.  
  196. echo json_encode($results);
  197. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement