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::*"); } $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 = $poster[0]->BannerPath; $poster = $bannerURL . $poster; 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) { echo $name . "
"; if(file_exists("posters/" . $name . ".jpg")) { echo "skipping..

"; 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 "SeriesName . "&seriesid=" . (string) $serie->seriesid . "\">Load
"; } } 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::*"); } $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 = $poster[0]->BannerPath; $poster = $bannerURL . $poster; 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..

"; continue; } $movie = json_decode(curl_download($movieAPIUrl . urlencode($movieName))); if(sizeof($movie->results) > 1) { foreach($movie->results as $result) { pa($result); echo "Load
"; } } 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')); } } } ?>