Ver Fonte

Added some features, fixed some stuff. etc.

Moritz Schmidt há 10 anos atrás
pai
commit
edd43efbdc
9 ficheiros alterados com 125 adições e 61 exclusões
  1. 0 0
      favicon.ico
  2. 10 0
      inc/controller.php
  3. 21 4
      inc/movieScraper.php
  4. 19 7
      inc/seriesScraper.php
  5. 3 1
      inc/user.php
  6. 63 43
      templates/admin.php
  7. 5 0
      templates/episode.php
  8. 1 1
      templates/header.php
  9. 3 5
      templates/scrape.php

+ 0 - 0
favicon.ico


+ 10 - 0
inc/controller.php

@@ -56,6 +56,15 @@ class Controller {
 			$this->scraper->update($request['seriesID']);
 			$this->scraper->update($request['seriesID']);
 		}
 		}
 
 
+		if(!empty($request['action']) && $request['action'] === "removeMovie") {
+			MovieScraper::remove($request['movieID']);
+		}
+
+		if(!empty($request['action']) && $request['action'] === "updateMovie") {
+			$this->scraper = new MovieScraper();
+			$this->scraper->update($request['movieID']);
+		}
+
 		if(!empty($request['action']) && $request['action'] === "updateUserInfo") {
 		if(!empty($request['action']) && $request['action'] === "updateUserInfo") {
 			User::update($request['newPassword'], $request['newPasswordConfirmation'], $request['newEmail'], $request['oldEmail']);
 			User::update($request['newPassword'], $request['newPasswordConfirmation'], $request['newEmail'], $request['oldEmail']);
 		}
 		}
@@ -94,6 +103,7 @@ class Controller {
 					$view->setTemplate('admin');
 					$view->setTemplate('admin');
 					$view->assign('sources', $GLOBALS['db']->getAllAssoc("sources"));
 					$view->assign('sources', $GLOBALS['db']->getAllAssoc("sources"));
 					$view->assign('series', Model::getSeries());
 					$view->assign('series', Model::getSeries());
+					$view->assign('movies', Model::getMovies());
 					break;
 					break;
 
 
 				case 'scrape':
 				case 'scrape':

+ 21 - 4
inc/movieScraper.php

@@ -21,7 +21,7 @@ class MovieScraper {
     return str_replace(".", " ", $output[1]);
     return str_replace(".", " ", $output[1]);
   }
   }
 
 
-  public static function sortByPopularity($movieA, $movieB) {    
+  public static function sortByPopularity($movieA, $movieB) {
     if($movieA['popularity'] == $movieB['popularity']) {
     if($movieA['popularity'] == $movieB['popularity']) {
       return 0;
       return 0;
     }
     }
@@ -29,6 +29,23 @@ class MovieScraper {
     return ($movieA['popularity'] < $movieB['popularity']) ? 1 : -1;
     return ($movieA['popularity'] < $movieB['popularity']) ? 1 : -1;
   }
   }
 
 
+  public static function remove($movieID) {
+    $movie = $GLOBALS['db']->getAllAssoc("movies", "id", $movieID);
+    unlink("img/posters/" . $movie[0]['poster']);
+    unlink("img/posters/" . $movie[0]['backdrop']);
+    $GLOBALS['db']->deleteRows("movies", "id", $movieID);
+    header("Location: " . $GLOBALS['conf']['baseURL'] . "?view=admin");
+  }
+
+  public static function update($movieID) {
+    $movie = $GLOBALS['db']->getAllAssoc("movies", "id", $movieID);
+
+    self::remove($movieID);
+
+    $this->downloadMovieByID($movie['moviedb-id'], $movie['path'], $movie['source']);
+    header("Location: " . $GLOBALS['conf']['baseURL'] . "?view=admin");
+  }
+
   public function scrapeFolder($sourceID) {
   public function scrapeFolder($sourceID) {
     if(!file_exists("img/posters")) {
     if(!file_exists("img/posters")) {
         mkdir("img/posters");
         mkdir("img/posters");
@@ -59,7 +76,7 @@ class MovieScraper {
         usort($movie['results'], array("MovieScraper", "sortByPopularity")); // sort results by popularity, so that you don't have to scroll like 500000x
         usort($movie['results'], array("MovieScraper", "sortByPopularity")); // sort results by popularity, so that you don't have to scroll like 500000x
         foreach($movie['results'] as $result) {
         foreach($movie['results'] as $result) {
           $this->outputText .= "<pre>" . print_r($result, true) . "</pre>" . PHP_EOL;
           $this->outputText .= "<pre>" . print_r($result, true) . "</pre>" . PHP_EOL;
-          $this->outputText .= "<a href=\"?view=scrape&action=scrapeSingleMovie&moviedbID=" . $result['id'] . "&path=" . urlencode($file) . "&sourceID=" . $sourceID . "\" target=\"_blank\">Load</a><br>" . PHP_EOL;
+          $this->outputText .= "<a href=\"?view=scrape&action=scrapeSingleMovie&moviedbID=" . $result['id'] . "&path=" . urlencode($file) . "&sourceID=" . $sourceID . "\" target=\"_blank\">Load</a><br /><br />" . PHP_EOL;
         }
         }
       }
       }
 
 
@@ -126,8 +143,8 @@ class MovieScraper {
       $movie['id'],
       $movie['id'],
       $movie['title'],
       $movie['title'],
       $path,
       $path,
-      $movie['poster_path'],
-      $movie['backdrop_path'],
+      ltrim($movie['poster_path'], "/"),
+      ltrim($movie['backdrop_path'], "/"),
       $movie['overview'],
       $movie['overview'],
       $sourceID
       $sourceID
     );
     );

+ 19 - 7
inc/seriesScraper.php

@@ -27,12 +27,23 @@ class SeriesScraper {
     $series = Model::getSeriesBySeriesID($seriesID);
     $series = Model::getSeriesBySeriesID($seriesID);
     $seasons = Model::getSeasonsBySeriesID($seriesID);
     $seasons = Model::getSeasonsBySeriesID($seriesID);
     foreach($seasons as $season) {
     foreach($seasons as $season) {
+      $episodes = $GLOBALS['db']->getAllAssoc("series-episodes", "season-id", $season['id']);
+      foreach($episodes as $episode) {
+        unlink("img/posters/" . $episode['thumb']);
+      }
       $GLOBALS['db']->deleteRows("series-episodes", "season-id", $season['id']);
       $GLOBALS['db']->deleteRows("series-episodes", "season-id", $season['id']);
     }
     }
+    $seasons = $GLOBALS['db']->getAllAssoc("series-seasons", "series-id", $seriesID);
+    foreach($seasons as $season) {
+      unlink("img/posters/" . $season['poster']);
+    }
     $GLOBALS['db']->deleteRows("series-seasons", "series-id", $seriesID);
     $GLOBALS['db']->deleteRows("series-seasons", "series-id", $seriesID);
+    $series = $GLOBALS['db']->getAllAssoc("series", "id", $seriesID);
+    unlink("img/posters/" . $series[0]['poster']);
+    unlink("img/posters/" . $series[0]['backdrop']);
     $GLOBALS['db']->deleteRows("series", "id", $seriesID);
     $GLOBALS['db']->deleteRows("series", "id", $seriesID);
 
 
-    // TODO: Remove files
+      header("Location: " . $GLOBALS['conf']['baseURL'] . "?view=admin");
   }
   }
 
 
   public function update($seriesID) {
   public function update($seriesID) {
@@ -41,6 +52,7 @@ class SeriesScraper {
     self::remove($seriesID);
     self::remove($seriesID);
 
 
     $this->downloadSeriesByID($series[0]['moviedb-id'], $series[0]['path'], $series[0]['source']);
     $this->downloadSeriesByID($series[0]['moviedb-id'], $series[0]['path'], $series[0]['source']);
+    header("Location: " . $GLOBALS['conf']['baseURL'] . "?view=admin");
   }
   }
 
 
   public function scrapeFolder($sourceID) {
   public function scrapeFolder($sourceID) {
@@ -51,7 +63,7 @@ class SeriesScraper {
     $source = $GLOBALS['db']->getAllAssoc("sources", "id", $sourceID);
     $source = $GLOBALS['db']->getAllAssoc("sources", "id", $sourceID);
 
 
     $dirList = scandir($source[0]['path']);
     $dirList = scandir($source[0]['path']);
-    $dirList = array_diff($dirList, array('.', '..', 'formatting.txt', '.Trash-1000'));
+    $dirList = array_diff($dirList, array('.', '..', 'formatting.txt', '.Trash-1000', 'queue.hbq'));
 
 
     foreach($dirList as $dir) {
     foreach($dirList as $dir) {
       $this->outputText .= "<b>" . $dir . "</b><br>" . PHP_EOL;
       $this->outputText .= "<b>" . $dir . "</b><br>" . PHP_EOL;
@@ -73,7 +85,7 @@ class SeriesScraper {
         usort($series['results'], array("MovieScraper", "sortByPopularity")); // sort results by popularity, so that you don't have to scroll like 500000x
         usort($series['results'], array("MovieScraper", "sortByPopularity")); // sort results by popularity, so that you don't have to scroll like 500000x
         foreach($series['results'] as $result) {
         foreach($series['results'] as $result) {
           $this->outputText .= "<pre>" . print_r($result, true) . "</pre>" . PHP_EOL;
           $this->outputText .= "<pre>" . print_r($result, true) . "</pre>" . PHP_EOL;
-          $this->outputText .= "<a href=\"?view=scrape&action=scrapeSingleTV&moviedbID=" . $result['id'] . "&path=" . urlencode($dir) . "&sourceID=" . $sourceID . "\" target=\"_blank\">Load</a><br>" . PHP_EOL; // TODO: this
+          $this->outputText .= "<a href=\"?view=scrape&action=scrapeSingleTV&moviedbID=" . $result['id'] . "&path=" . urlencode($dir) . "&sourceID=" . $sourceID . "\" target=\"_blank\">Load</a><br /><br />" . PHP_EOL; // TODO: this
         }
         }
       }
       }
 
 
@@ -153,8 +165,8 @@ class SeriesScraper {
       $series['id'],
       $series['id'],
       $series['name'],
       $series['name'],
       $path,
       $path,
-      $series['poster_path'],
-      $series['backdrop_path'],
+      ltrim($series['poster_path'], "/"),
+      ltrim($series['backdrop_path'], "/"),
       $series['overview'],
       $series['overview'],
       $sourceID
       $sourceID
     );
     );
@@ -176,7 +188,7 @@ class SeriesScraper {
       $vals = array(
       $vals = array(
         $dbSeriesID,
         $dbSeriesID,
         $series['seasons'][$season]['season_number'],
         $series['seasons'][$season]['season_number'],
-        $series['seasons'][$season]['poster_path']
+        ltrim($series['seasons'][$season]['poster_path'], "/")
       );
       );
 
 
       $dbSeasonID = $GLOBALS['db'] -> insertRow("series-seasons", $cols, $vals);
       $dbSeasonID = $GLOBALS['db'] -> insertRow("series-seasons", $cols, $vals);
@@ -211,7 +223,7 @@ class SeriesScraper {
           $dbSeasonID,
           $dbSeasonID,
           $episodes[$episode]['episode_number'],
           $episodes[$episode]['episode_number'],
           $episodes[$episode]['name'],
           $episodes[$episode]['name'],
-          $episodes[$episode]['still_path'],
+          ltrim($episodes[$episode]['still_path'], "/"),
           $localEpisode
           $localEpisode
         );
         );
 
 

+ 3 - 1
inc/user.php

@@ -58,7 +58,7 @@ class User {
 
 
     $vals = array(
     $vals = array(
       $email,
       $email,
-      $password,
+      md5($password),
     );
     );
 
 
     $GLOBALS['db']->insertRow("users", $cols, $vals);
     $GLOBALS['db']->insertRow("users", $cols, $vals);
@@ -68,6 +68,8 @@ class User {
 
 
     mail($email, "Moeflix invite", $msg, 'From: moritz+moeflix@mmnx.de');
     mail($email, "Moeflix invite", $msg, 'From: moritz+moeflix@mmnx.de');
 
 
+    header("Location: " . $GLOBALS['conf']['baseURL'] . "?view=admin");
+
   }
   }
 
 
   /**
   /**

+ 63 - 43
templates/admin.php

@@ -1,49 +1,69 @@
-    <h2>you're in admin sheeeet</h2>
-    <h1>Invite</h1>
-    <form class="form-horizontal" action="<?php echo $GLOBALS['conf']['baseURL']; ?>?view=admin&action=invite" method="post">
-      <div class="form-group">
-        <label for="inviteMail" class="col-sm-2 control-label">Email</label>
-        <div class="col-sm-6">
-          <input type="email" class="form-control" id="inviteMail" name="inviteMail" placeholder="Email">
+    <div class="container">
+      <h2>you're in admin sheeeet</h2>
+      <h1>Invite</h1>
+      <form class="form-horizontal" action="<?php echo $GLOBALS['conf']['baseURL']; ?>?view=admin&action=invite" method="post">
+        <div class="form-group">
+          <label for="inviteMail" class="col-sm-2 control-label">Email</label>
+          <div class="col-sm-6">
+            <input type="email" class="form-control" id="inviteMail" name="inviteMail" placeholder="Email">
+          </div>
         </div>
         </div>
-      </div>
-      <div class="form-group">
-        <div class="col-sm-offset-2 col-sm-10">
-          <button type="submit" class="btn btn-default">Invite</button>
+        <div class="form-group">
+          <div class="col-sm-offset-2 col-sm-10">
+            <button type="submit" class="btn btn-default">Invite</button>
+          </div>
         </div>
         </div>
-      </div>
-    </form>
-
-    <h1>Sources</h1>
-    <?php
-      foreach($this->_['sources'] as $source) {
-        echo "<a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=scrape&action=scrape&sourceID=" . $source['id'] . "\"><i class=\"fa fa-search\"></i></a> " . $source['name'] . " - " . $source['path'];
-        echo "<br>";
-      }
-      ?>
-      <hr>
-      <h1>Series</h1>
-      <table class="table table-striped">
-        <thead>
-          <tr>
-            <td>#</td>
-            <td>MovieDB-ID</td>
-            <td>Name</td>
-            <td></td>
-            <td></td>
-          </tr>
-        </thead>
+      </form>
 
 
+      <h1>Sources</h1>
       <?php
       <?php
+        foreach($this->_['sources'] as $source) {
+          echo "<a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=scrape&action=scrape&sourceID=" . $source['id'] . "\"><i class=\"fa fa-search\"></i></a> " . $source['name'] . " - " . $source['path'];
+          echo "<br>";
+        }
+        ?>
+        <hr>
+        <h1>Series</h1>
+        <table class="table table-striped">
+          <thead>
+            <tr>
+              <td>#</td>
+              <td>MovieDB-ID</td>
+              <td>Name</td>
+              <td></td>
+              <td></td>
+            </tr>
+          </thead>
 
 
-      foreach($this->_['series'] as $series) {
-        echo "<tr>";
-        echo "<td>" . $series['id'] . "</td>";
-        echo "<td>" . $series['moviedb-id'] . "</td>";
-        echo "<td>" . $series['name'] . "</td>";
-        echo "<td><a href=\"" . $GLOBALS['config']['baseURL'] . "?view=admin&action=updateSeries&seriesID=" . $series['id'] . "\"><i class=\"fa fa-refresh\"></i></a></td>";
-        echo "<td><a href=\"" . $GLOBALS['config']['baseURL'] . "?view=admin&action=removeSeries&seriesID=" . $series['id'] . "\"><i class=\"fa fa-trash\"></i></a></td>";
-      }
+        <?php foreach($this->_['series'] as $series) {
+          echo "<tr>";
+          echo "<td>" . $series['id'] . "</td>";
+          echo "<td>" . $series['moviedb-id'] . "</td>";
+          echo "<td>" . $series['name'] . "</td>";
+          echo "<td><a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=admin&action=updateSeries&seriesID=" . $series['id'] . "\"><i class=\"fa fa-refresh\"></i></a></td>";
+          echo "<td><a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=admin&action=removeSeries&seriesID=" . $series['id'] . "\"><i class=\"fa fa-trash\"></i></a></td>";
+          echo "</tr>";
+        } ?>
+      </table>
 
 
-      ?>
-    </table>
+      <br />
+      <h1>Movies</h1>
+      <table class="table table-striped">
+        <thead>
+          <td>#</td>
+          <td>MovieDB-ID</td>
+          <td>Name</td>
+          <td></td>
+          <td></td>
+        </thead>
+        <?php foreach ($this->_['movies'] as $movie) {
+          echo "<tr>";
+          echo "<td>" . $movie['id'] . "</td>";
+          echo "<td>" . $movie['moviedb-id'] . "</td>";
+          echo "<td>" . $movie['name'] . "</td>";
+          echo "<td><a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=admin&action=updateMovie&movieID=" . $movie['id'] . "\"><i class=\"fa fa-refresh\"></i></a></td>";
+          echo "<td><a href=\"" . $GLOBALS['conf']['baseURL'] . "?view=admin&action=removeMovie&movieID=" . $movie['id'] . "\"><i class=\"fa fa-trash\"></i></a></td>";
+          echo "</tr>";
+        } ?>
+      </table>
+    </div>

+ 5 - 0
templates/episode.php

@@ -1,5 +1,10 @@
 <div class="container-fluid">
 <div class="container-fluid">
   <h1><?php echo $this->_['episode'][0]['number'] . " - " . $this->_['episode'][0]['name']; ?></h1>
   <h1><?php echo $this->_['episode'][0]['number'] . " - " . $this->_['episode'][0]['name']; ?></h1>
+  <div class="row text-center">
+    <p>
+      <a href="<?php echo $GLOBALS['conf']['baseURL']; ?>readfile.php?file=<?php echo urlencode(base64_encode($this->_['videoFile'])); ?>">Download</a> | <input type="text" value="https://bridge.mmnx.de/videos/readfile.php?file=<?php echo urlencode(base64_encode($this->_['videoFile'])); ?>" /> <sub>Kopieren für Wiedergabe in Medienplayer (Netzwerkstream)</sub>
+    </p>
+  </div>
   <div class="row">
   <div class="row">
     <!--<input type="text" value="https://yolo:amk@bridge.mmnx.de/videos/readfile.php?file=/media/Serien/American Dad/S01/American.Dad-S01E01-Pilot.mp4" /> <sub>Kopieren für Wiedergabe in Medienplayer (Netzwerkstream)</sub>-->
     <!--<input type="text" value="https://yolo:amk@bridge.mmnx.de/videos/readfile.php?file=/media/Serien/American Dad/S01/American.Dad-S01E01-Pilot.mp4" /> <sub>Kopieren für Wiedergabe in Medienplayer (Netzwerkstream)</sub>-->
 
 

+ 1 - 1
templates/header.php

@@ -94,7 +94,7 @@
   <body>
   <body>
 
 
     <div id="logo">
     <div id="logo">
-      <a href="<?php echo $GLOBALS['conf']['baseURL']; ?>"><img src="<?php echo $GLOBALS['conf']['baseURL']; ?>/img/moeflix.png" alt="moeflix"></a>
+      <a href="<?php echo $GLOBALS['conf']['baseURL']; ?>"><img src="<?php echo $GLOBALS['conf']['baseURL']; ?>img/moeflix.png" alt="moeflix"></a>
     </div>
     </div>
     <div id="user-menu">
     <div id="user-menu">
       <span>
       <span>

+ 3 - 5
templates/scrape.php

@@ -1,5 +1,3 @@
-<?php
-
-echo $this->_['scraper']->getOutputText();
-
-?>
+<div class="container">
+  <?php echo $this->_['scraper']->getOutputText(); ?>
+</div>