| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500 |
- <?php
- /*
- ignore_user_abort(true);
- require('functions.php');
- // Serien
- $apiURL = "http://thetvdb.com/api/084F3E73D176AD88/";
- $bannerURL = "http://www.thetvdb.com/banners/";
- if(!file_exists("posters")) {
- mkdir("posters");
- }
- // http://www.thetvdb.com/wiki/index.php/Programmers_API
- // Step 2 (dev)
- $languages = curl_download($apiURL . "languages.xml");
- $languages = new SimpleXMLElement($languages);
- $german = $languages->xpath('/Languages/Language/abbreviation[.="de"]/parent::*');
- $english = $languages->xpath('/Languages/Language/abbreviation[.="en"]/parent::*');
- // Step 1
- $mirrors = curl_download($apiURL . "mirrors.xml");
- $mirrors = new SimpleXMLElement($mirrors);
- // xml mirrors
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="1"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="3"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="5"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- // banner mirrors
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="2"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="3"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="6"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- // zip mirrors
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="4"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="5"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="6"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- // Step 2
- $serverTime = curl_download("http://thetvdb.com/api/Updates.php?type=none");
- $serverTime = new SimpleXMLElement($serverTime);
- // Step 3
- if(isset($_REQUEST['action']) && $_REQUEST['action'] == "singleDownload") {
- $seriesName = $_REQUEST['seriesname'];
- $seriesID = $_REQUEST['seriesid'];
- $series = curl_download($apiURL . "series/" . $seriesID . "/" . (string) $german[0]->abbreviation . ".xml");
- if(strpos($series, 'Not Found') !== false) {
- $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::*");
- }
- $poster = $poster[0]->BannerPath;
- $poster = $bannerURL . $poster;
- $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'));
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $german[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("posters/" . $seriesName . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- $episodeURL = $bannerURL . $episode->filename;
- file_put_contents("posters/" . $seriesName . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $english[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("posters/" . $seriesName . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- $episodeURL = $bannerURL . $episode->filename;
- file_put_contents("posters/" . $seriesName . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- $series = new SimpleXMLElement($series);
- file_put_contents("posters/" . $seriesName . ".jpg", fopen($poster, 'r'));
- echo "Done.";
- } else if(!isset($_REQUEST['action'])) {
- $list = scandir("/media/Serien");
- $list = array_diff($list, array('.', '..'));
- foreach($list as $name) {
- $object = str_split($name, sizeof($name));
- if($object[0] == "." && $object[1] != ".") {
- continue;
- }
- echo $name . "<br>";
- if(file_exists("posters/" . $name . ".jpg")) {
- echo "skipping..<br><br>";
- continue;
- }
- $series = curl_download("http://thetvdb.com/api/GetSeries.php?seriesname=" . urlencode($name));
- $series = new SimpleXMLElement($series);
- if(sizeof($series) > 1) {
- foreach($series as $serie) {
- pa($serie);
- echo "<a target=\"_blank\" href=\"?action=singleDownload&seriesname=" . (string) $serie->SeriesName . "&seriesid=" . (string) $serie->seriesid . "\">Load</a><br>";
- }
- } else {
- $seriesID = (string) $series->Series->seriesid[0];
- $series = curl_download($apiURL . "series/" . $seriesID . "/" . (string) $german[0]->abbreviation . ".xml");
- if(strpos($series, 'Not Found') !== false) {
- $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::*");
- }
- $poster = $poster[0]->BannerPath;
- $poster = $bannerURL . $poster;
- $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'));
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $german[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- $episodeURL = $bannerURL . $episode->filename;
- file_put_contents("posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $english[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- $episodeURL = $bannerURL . $episode->filename;
- file_put_contents("posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- $series = new SimpleXMLElement($series);
- file_put_contents("posters/" . $name . ".jpg", fopen($poster, 'r'));
- }
- }
- }
- */
- // Filme
- $movieAPIUrl = "https://api.themoviedb.org/3/search/movie?api_key=a39779a38e0619f8ae58b09f64522597&query=";
- $moviePosterURL = "https://image.tmdb.org/t/p/original/";
- 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&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.";
- } else if(!isset($_REQUEST['action'])) {
- $list = scandir("/media/Filme");
- $list = array_diff($list, array('.', '..'));
- foreach($list as $movieName) {
- $movieName = explode('.', $movieName);
- unset($movieName[sizeof($movieName) - 1]);
- unset($movieName[sizeof($movieName) - 1]);
- $movieName = implode(' ', $movieName);
- $movieName = str_replace(" Directors Cut", "", $movieName);
- pa($movieName);
- if(file_exists("posters/" . $movieName . ".jpg")) {
- echo "skipping..<br><br>";
- continue;
- }
- $movie = json_decode(curl_download($movieAPIUrl . urlencode($movieName)));
- if(sizeof($movie->results) > 1) {
- foreach($movie->results as $result) {
- pa($result);
- echo "<a target=\"_blank\" href=\"?action=singleDownloadMovie&moviename=" . $movieName . "&movieid=" . (string) $result->id . "\">Load</a><br>";
- }
- } else {
- $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'));
- }
- }
- }
- /*
- ?>
- $languages = curl_download($this->apiURL . "languages.xml");
- $languages = new SimpleXMLElement($languages);
- $german = $languages->xpath('/Languages/Language/abbreviation[.="de"]/parent::*');
- $english = $languages->xpath('/Languages/Language/abbreviation[.="en"]/parent::*');
- $mirrors = curl_download($this->apiURL . "mirrors.xml");
- $mirrors = new SimpleXMLElement($mirrors);
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="1"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="3"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="5"]/parent::*');
- if(sizeof($xmlMirrors < 1)) {
- $xmlMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="2"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="3"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="6"]/parent::*');
- if(sizeof($bannerMirrors < 1)) {
- $bannerMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="4"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="5"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="6"]/parent::*');
- if(sizeof($zipMirrors < 1)) {
- $zipMirrors = $mirrors->xpath('/Mirrors/Mirror/typemask[.="7"]/parent::*');
- }
- }
- }
- $serverTime = curl_download("http://thetvdb.com/api/Updates.php?type=none");
- $serverTime = new SimpleXMLElement($serverTime);
- $list = scandir($path);
- $list = array_diff($list, array('.', '..', 'formatting.txt'));
- foreach($list as $name) {
- $object = str_split($name, sizeof($name));
- if($object[0] == "." && $object[1] != ".") { // Ignore dotfiles
- continue;
- }
- error_log($name);
- $this->outputText .= $name . "<br>" . PHP_EOL;
- if(file_exists("img/posters/" . $name . ".jpg")) {
- $this->outputText .= "skipping..<br><br>" . PHP_EOL;
- continue;
- }
- $series = curl_download("http://thetvdb.com/api/GetSeries.php?seriesname=" . urlencode($name));
- $series = new SimpleXMLElement($series);
- if(sizeof($series) > 1) {
- foreach($series as $serie) {
- $this->outputText .= "<pre>" . print_r($serie, true) . "</pre>" . PHP_EOL;
- $this->outputText .= "<a target=\"_blank\" href=\"?action=singleDownload&seriesname=" . (string) $serie->SeriesName . "&seriesid=" . (string) $serie->seriesid . "\">Load</a><br>" . PHP_EOL;
- }
- } else {
- error_log($seriesID);
- $seriesID = (string) $series->Series->seriesid[0];
- $series = curl_download($this->apiURL . "series/" . $seriesID . "/" . (string) $german[0]->abbreviation . ".xml");
- if(strpos($series, 'Not Found') !== false) {
- $series = curl_download($this->apiURL . "series/" . $seriesID . "/" . (string) $english[0]->abbreviation . ".xml");
- }
- $banners = curl_download($this->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::*");
- }
- $poster = $poster[0]->BannerPath;
- $poster = $this->bannerURL . $poster;
- file_put_contents("img/posters/" . $name . ".jpg", fopen($poster, 'r'));
- $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 = $this->bannerURL . $season->BannerPath;
- file_put_contents("img/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("img/posters/" . $name . "_" . (string) $season->Season[0] . ".jpg")) {
- continue;
- }
- $seasonURL = $this->bannerURL . $season->BannerPath;
- file_put_contents("img/posters/" . $name . "_" . (string) $season->Season[0] . ".jpg", fopen($seasonURL, 'r'));
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $german[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("img/posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- if(!empty($episode->filename)) {
- $episodeURL = $this->bannerURL . $episode->filename;
- file_put_contents("img/posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- }
- $episodes = curl_download("http://thetvdb.com/api/084F3E73D176AD88/series/" . $seriesID . "/all/" . $english[0]->abbreviation . ".xml");
- $episodes = new SimpleXMLElement($episodes);
- if(sizeof($episodes->Episode) > 0) {
- foreach($episodes->Episode as $episode) {
- if(file_exists("img/posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg")) {
- continue;
- }
- if(!empty($episode->filename)) {
- $episodeURL = $this->bannerURL . $episode->filename;
- file_put_contents("img/posters/" . $name . "_" . (string) $episode->SeasonNumber[0] . "_" . (string) $episode->EpisodeNumber . ".jpg", fopen($episodeURL, 'r'));
- }
- }
- }
- error_log("serie done");
- }
- error_log("done");
- }
|