Selaa lähdekoodia

New folder up button, localised posters, posters for seasons, moeflix logo

Moritz Schmidt 10 vuotta sitten
vanhempi
commit
045a1da1d7
5 muutettua tiedostoa jossa 93 lisäystä ja 29 poistoa
  1. BIN
      folder_up.png
  2. 7 0
      functions.php
  3. 20 3
      index.php
  4. BIN
      moeflix.png
  5. 66 26
      updateMetadata.php

BIN
folder_up.png


+ 7 - 0
functions.php

@@ -14,6 +14,13 @@ function getImageByName($folder) {
 
     if(is_dir($folder)) {
         $name = explode('/', $folder);
+
+        $zeichenkette = $name[sizeof($name) - 1];
+        $suchmuster = "/S[0-9]+/";
+        preg_match_all($suchmuster, $zeichenkette, $treffer);
+        if(sizeof($treffer[0]) > 0) {
+            return "posters/" . $name[3] . "_" . ltrim(str_replace('S', '', $zeichenkette), "0") . ".jpg";
+        }
         return "posters/" . $name[3] . ".jpg";
     } else {
         $movieName = explode('/', $folder);

+ 20 - 3
index.php

@@ -14,6 +14,15 @@ require('functions.php');
 
         <style>
 
+            #logo {
+                margin: 0 auto;
+                text-align: center;
+            }
+
+            #logo > img {
+                height: 200px;
+            }
+
             .col-sm-3 > div > a > img {
                 width: 100%;
             }
@@ -47,6 +56,10 @@ require('functions.php');
     </head>
     <body>
 
+        <div id="logo">
+            <img src="moeflix.png" alt="moeflix">
+        </div>
+
         <div class="container-fluid">
 
         <?php
@@ -82,12 +95,14 @@ require('functions.php');
             echo "<h1>" . $_GET['path'] . "</h1>";
             if(is_dir($_GET['path'])) {
                 $list = scandir($_GET['path']);
-                $list = array_diff($list, array('.'));
+                $list = array_diff($list, array('.', 'queue.hbq'));
                 echo "<div class=\"row\">";
                 foreach($list as $object) {
                     if($object == "..") {
                         if(in_array($_GET['path'], $CONFIG['paths'])) {
-                            echo "<a href=\"?path=\">Home</a><br>";
+                            echo "<div class=\"col-sm-3\"><div class=\"image-zoom\">";
+                            echo "<a href=\"?path=\"><img src=\"/folder_up.png\" alt=\"folder up\"></a><br>";
+                            echo "</div></div>";
                         } else {
                             $paths = explode('/', $_GET['path']);
                             $paths = array_diff($paths, array($paths[sizeof($paths) - 1]));
@@ -99,7 +114,9 @@ require('functions.php');
                                     $pathv .= $path . "/";
                                 }
                             }
-                            echo "<a href=\"?path=" . $pathv . "\">" . $object . "</a><br>";
+                            echo "<div class=\"col-sm-3\"><div class=\"image-zoom\">";
+                            echo "<a href=\"?path=" . $pathv . "\"><img src=\"/folder_up.png\" alt=\"folder up\"></a><br>";
+                            echo "</div></div>";
                         }
                     } else {
                         echo "<div class=\"col-sm-3\"><div class=\"image-zoom\">";

BIN
moeflix.png


+ 66 - 26
updateMetadata.php

@@ -90,8 +90,38 @@ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownload") {
         $series = curl_download($apiURL . "series/" . $seriesID . "/" . (string) $english[0]->abbreviation . ".xml");
     }
 
+    $banners = curl_download($apiURL . "series/" . $seriesID . "/banners.xml");
+    $banners = new SimpleXMLElement($banners);
+
+    $poster = $banners->xpath("/Banners/Banner/BannerType[text()='poster']/../Language[text()='" . $german[0]->abbreviation . "']/parent::*");
+
+    if(sizeof($poster) < 1) {
+        $poster = $banners->xpath("/Banners/Banner/BannerType[text()='poster']/../Language[text()='" . $english[0]->abbreviation . "']/parent::*");
+    }
+
+    $seasons = $banners->xpath("/Banners/Banner/BannerType[text()='season']/../BannerType2[text()='season']/../Language[text()='" . $german[0]->abbreviation . "']/parent::*");
+
+    if(sizeof($seasons) > 0) {
+        foreach($seasons as $season) {
+            $seasonURL = $bannerURL . $season->BannerPath;
+            file_put_contents("posters/" . $seriesName . "_" . (string) $season->Season[0] . ".jpg", fopen($seasonURL, 'r'));
+        }
+    }
+
+    $seasons = $banners->xpath("/Banners/Banner/BannerType[text()='season']/../BannerType2[text()='season']/../Language[text()='" . $english[0]->abbreviation . "']/parent::*");
+
+    if(sizeof($seasons) > 0) {
+        foreach($seasons as $season) {
+            if(file_exists("posters/" . $seriesName . "_" . (string) $season->Season[0] . ".jpg")) {
+                continue;
+            }
+            $seasonURL = $bannerURL . $season->BannerPath;
+            file_put_contents("posters/" . $seriesName . "_" . (string) $season->Season[0] . ".jpg", fopen($seasonURL, 'r'));
+        }
+    }
+
     $series = new SimpleXMLElement($series);
-    $poster = (string) $series->Series->poster;
+    $poster = $poster[0]->BannerPath;
     $poster = $bannerURL . $poster;
 
     file_put_contents("posters/" . $seriesName . ".jpg", fopen($poster, 'r'));
@@ -131,13 +161,42 @@ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownload") {
                 $series = curl_download($apiURL . "series/" . $seriesID . "/" . (string) $english[0]->abbreviation . ".xml");
             }
 
+            $banners = curl_download($apiURL . "series/" . $seriesID . "/banners.xml");
+            $banners = new SimpleXMLElement($banners);
+
+            $poster = $banners->xpath("/Banners/Banner/BannerType[text()='poster']/../Language[text()='" . $german[0]->abbreviation . "']/parent::*");
+
+            if(sizeof($poster) < 1) {
+                $poster = $banners->xpath("/Banners/Banner/BannerType[text()='poster']/../Language[text()='" . $english[0]->abbreviation . "']/parent::*");
+            }
+
+            $seasons = $banners->xpath("/Banners/Banner/BannerType[text()='season']/../BannerType2[text()='season']/../Language[text()='" . $german[0]->abbreviation . "']/parent::*");
+
+            if(sizeof($seasons) > 0) {
+                foreach($seasons as $season) {
+                    $seasonURL = $bannerURL . $season->BannerPath;
+                    file_put_contents("posters/" . $name . "_" . (string) $season->Season[0] . ".jpg", fopen($seasonURL, 'r'));
+                }
+            }
+
+            $seasons = $banners->xpath("/Banners/Banner/BannerType[text()='season']/../BannerType2[text()='season']/../Language[text()='" . $english[0]->abbreviation . "']/parent::*");
+
+            if(sizeof($seasons) > 0) {
+                foreach($seasons as $season) {
+                    if(file_exists("posters/" . $name . "_" . (string) $season->Season[0] . ".jpg")) {
+                        continue;
+                    }
+                    $seasonURL = $bannerURL . $season->BannerPath;
+                    file_put_contents("posters/" . $name . "_" . (string) $season->Season[0] . ".jpg", fopen($seasonURL, 'r'));
+                }
+            }
+
             $series = new SimpleXMLElement($series);
-            $poster = (string) $series->Series->poster;
+            $poster = $poster[0]->BannerPath;
             $poster = $bannerURL . $poster;
 
             file_put_contents("posters/" . $name . ".jpg", fopen($poster, 'r'));
         }
-
     }
 }
 
@@ -153,14 +212,13 @@ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownloadMovie") {
     $movieName = $_REQUEST['moviename'];
     $movieID = $_REQUEST['movieid'];
 
-    $movie = curl_download("https://api.themoviedb.org/3/movie/" . $movieID . "?api_key=a39779a38e0619f8ae58b09f64522597");
+    $movie = curl_download("https://api.themoviedb.org/3/movie/" . $movieID . "?api_key=a39779a38e0619f8ae58b09f64522597&language=de&include_image_language=de");
 
     if(strpos($movie, 'not be found') !== false) {
         echo "something went wrong";
     }
 
     $movie = json_decode($movie);
-
     file_put_contents("posters/" . $movieName . ".jpg", fopen($moviePosterURL . $movie->poster_path, 'r'));
 
     echo "Done.";
@@ -175,7 +233,6 @@ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownloadMovie") {
         unset($movieName[sizeof($movieName) - 1]);
         unset($movieName[sizeof($movieName) - 1]);
         $movieName = implode(' ', $movieName);
-
         $movieName = str_replace(" Directors Cut", "", $movieName);
 
         pa($movieName);
@@ -188,35 +245,18 @@ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownloadMovie") {
         $movie = json_decode(curl_download($movieAPIUrl . urlencode($movieName)));
 
         if(sizeof($movie->results) > 1) {
-            // TODO: select thingy
-
             foreach($movie->results as $result) {
                 pa($result);
 
                 echo "<a target=\"_blank\" href=\"?action=singleDownloadMovie&moviename=" . $movieName . "&movieid=" . (string) $result->id . "\">Load</a><br>";
             }
         } else {
-            $poster = $moviePosterURL . $movie->results[0]->poster_path;
+            $movie = json_decode(curl_download("https://api.themoviedb.org/3/movie/" . (string) $movie->results[0]->id . "?api_key=a39779a38e0619f8ae58b09f64522597&language=de&include_image_language=de"));
+
+            $poster = $moviePosterURL . $movie->poster_path;
             file_put_contents("posters/" . $movieName . ".jpg", fopen($poster, 'r'));
         }
     }
 }
 
-
-
-
-
-//pa($list);
-
-
-//$movie = json_decode(curl_download($movieAPIUrl . "Lucy"));
-
-//pa($movie);
-
-
-
-
-
-
-
 ?>