|
@@ -69,7 +69,8 @@ class SeriesScraper {
|
|
|
$this->outputText .= "<b>" . $dir . "</b><br>" . PHP_EOL;
|
|
$this->outputText .= "<b>" . $dir . "</b><br>" . PHP_EOL;
|
|
|
|
|
|
|
|
if($GLOBALS['db']->countRows("series", "path", $dir) > 0) {
|
|
if($GLOBALS['db']->countRows("series", "path", $dir) > 0) {
|
|
|
- $this->outputText .= "Exists, skipping..<br><br>" . PHP_EOL;
|
|
|
|
|
|
|
+ $this->outputText .= "Exists, updating..<br><br>" . PHP_EOL;
|
|
|
|
|
+ self::updateByID($GLOBALS['db']->getString("id", "series", "path", $dir));
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -82,7 +83,7 @@ class SeriesScraper {
|
|
|
} else if($series['total_results'] < 1) {
|
|
} else if($series['total_results'] < 1) {
|
|
|
$this->outputText .= "<span style=\"color: red;\">Not found!!</span><br>" . PHP_EOL;
|
|
$this->outputText .= "<span style=\"color: red;\">Not found!!</span><br>" . PHP_EOL;
|
|
|
} else { // multiple search results
|
|
} else { // multiple search results
|
|
|
- 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 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 /><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
|
|
@@ -90,46 +91,6 @@ class SeriesScraper {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->outputText .= "<br>" . PHP_EOL;
|
|
$this->outputText .= "<br>" . PHP_EOL;
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
-
|
|
|
|
|
- Array
|
|
|
|
|
- (
|
|
|
|
|
- [page] => 1
|
|
|
|
|
- [results] => Array
|
|
|
|
|
- (
|
|
|
|
|
- [0] => Array
|
|
|
|
|
- (
|
|
|
|
|
- [poster_path] => /hDlezfMSw8oXIFNZ7B9fFLrV8kd.jpg
|
|
|
|
|
- [popularity] => 1.006821
|
|
|
|
|
- [id] => 15826
|
|
|
|
|
- [backdrop_path] => /meQN6iuOulLwOV8LNO6S9z3bJBY.jpg
|
|
|
|
|
- [vote_average] => 7
|
|
|
|
|
- [overview] => 1000 Ways to Die is an anthology television series that [...]
|
|
|
|
|
- [first_air_date] => 2009-02-04
|
|
|
|
|
- [origin_country] => Array
|
|
|
|
|
- (
|
|
|
|
|
- [0] => US
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- [genre_ids] => Array
|
|
|
|
|
- (
|
|
|
|
|
- [0] => 99
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- [original_language] => en
|
|
|
|
|
- [vote_count] => 1
|
|
|
|
|
- [name] => 1000 Ways to Die
|
|
|
|
|
- [original_name] => 1000 Ways to Die
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- [total_results] => 1
|
|
|
|
|
- [total_pages] => 1
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- */
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -237,4 +198,58 @@ class SeriesScraper {
|
|
|
|
|
|
|
|
$this->outputText .= "Done.";
|
|
$this->outputText .= "Done.";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function updateByID($seriesID) {
|
|
|
|
|
+ /*if($seriesID != 208) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }*/
|
|
|
|
|
+
|
|
|
|
|
+ error_log($seriesID);
|
|
|
|
|
+
|
|
|
|
|
+ $series = $GLOBALS['db']->getAllAssoc("series", "id", $seriesID);
|
|
|
|
|
+ $seriesDB = json_decode(curl_download("http://api.themoviedb.org/3/tv/" . $series[0]['moviedb-id'] . "?api_key=a39779a38e0619f8ae58b09f64522597&language=de&include_image_language=de"), true);
|
|
|
|
|
+
|
|
|
|
|
+ if($series[0]['poster'] != ltrim($seriesDB['poster_path'], "/")) { // poster
|
|
|
|
|
+ error_log("New Poster, old: " . $series[0]['poster'] . " new: " . ltrim($seriesDB['poster_path'], "/"));
|
|
|
|
|
+ unlink("img/posters/" . $series[0]['poster']);
|
|
|
|
|
+ file_put_contents("img/posters" . $seriesDB['poster_path'], fopen($this->bannerURL . $seriesDB['poster_path'], 'r'));
|
|
|
|
|
+ $GLOBALS['db']->updateRow("series", "poster", '"' . ltrim($seriesDB['poster_path'], "/") . '"', "id", $seriesID);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($series[0]['backdrop'] != ltrim($seriesDB['backdrop_path'], "/")) { // backdrop
|
|
|
|
|
+ error_log("New Backdrop, old: " . $series[0]['backdrop'] . " new: " . ltrim($seriesDB['backdrop_path'], "/"));
|
|
|
|
|
+ unlink("img/posters/" . $series[0]['backdrop']);
|
|
|
|
|
+ file_put_contents("img/posters" . $seriesDB['backdrop_path'], fopen($this->bannerURL . $seriesDB['backdrop_path'], 'r'));
|
|
|
|
|
+ $GLOBALS['db']->updateRow("series", "backdrop", '"' . ltrim($seriesDB['backdrop_path'], "/") . '"', "id", $seriesID);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $seasons = $GLOBALS['db']->getAllAssoc("series-seasons", "series-id", $seriesID);
|
|
|
|
|
+
|
|
|
|
|
+ foreach($seasons as $season) { // TODO: check for new seasons
|
|
|
|
|
+ $seasonDB = array_search(ltrim($season['number'], 0), array_column($seriesDB['seasons'], 'season_number'));
|
|
|
|
|
+ $seasonDB = $seriesDB['seasons'][$seasonDB];
|
|
|
|
|
+
|
|
|
|
|
+ if($season['poster'] != ltrim($seasonDB['poster_path'], "/")) {
|
|
|
|
|
+ error_log("New Season-Poster, old: " . $season['poster'] . " new: " . ltrim($seasonDB['poster_path'], "/"));
|
|
|
|
|
+ unlink("img/posters/" . $season['poster']);
|
|
|
|
|
+ file_put_contents("img/posters" . $seasonDB['poster_path'], fopen($this->bannerURL . $seasonDB['poster_path'], 'r'));
|
|
|
|
|
+ $GLOBALS['db']->updateRow("series-seasons", "poster", '"' . ltrim($seasonDB['poster_path'], "/") . '"', "id", $season['id']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $episodesDB = json_decode(curl_download("http://api.themoviedb.org/3/tv/" . $series[0]['moviedb-id'] . "/season/" . $season['number'] . "?api_key=a39779a38e0619f8ae58b09f64522597&language=de&include_image_language=de"), true);
|
|
|
|
|
+
|
|
|
|
|
+ $episodes = $GLOBALS['db']->getAllAssoc("series-episodes", "season-id", $season['id']);
|
|
|
|
|
+ foreach($episodes as $episode) {
|
|
|
|
|
+ $episodeDB = array_search($episode['number'], array_column($episodesDB['episodes'], 'episode_number'));
|
|
|
|
|
+ $episodeDB = $episodesDB['episodes'][$episodeDB];
|
|
|
|
|
+
|
|
|
|
|
+ if($episode['thumb'] != ltrim($episodeDB['still_path'], "/")) {
|
|
|
|
|
+ error_log("New Episode-Poster, old: " . $episode['thumb'] . " new: " . ltrim($episodeDB['still_path'], "/"));
|
|
|
|
|
+ unlink("img/posters/" . $episode['thumb']);
|
|
|
|
|
+ file_put_contents("img/posters" . $episodeDB['still_path'], fopen($this->bannerURL . $episodeDB['still_path'], 'r'));
|
|
|
|
|
+ $GLOBALS['db']->updateRow("series-episodes", "thumb", '"' . ltrim($episodeDB['still_path'], "/") . '"', "id", $episode['id']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|