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 . "
";
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::*");
}
$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..
";
continue;
}
$movie = json_decode(curl_download($movieAPIUrl . urlencode($movieName)));
if(sizeof($movie->results) > 1) {
foreach($movie->results as $result) {
pa($result);
echo "id . "\">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'));
}
}
}
/*
?>
$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 . "
" . PHP_EOL;
if(file_exists("img/posters/" . $name . ".jpg")) {
$this->outputText .= "skipping..
" . 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 .= "
" . print_r($serie, true) . "" . PHP_EOL; $this->outputText .= "SeriesName . "&seriesid=" . (string) $serie->seriesid . "\">Load