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");
}
$series = new SimpleXMLElement($series);
$poster = (string) $series->Series->poster;
$poster = $bannerURL . $poster;
file_put_contents("posters/" . $seriesName . ".jpg", fopen($poster, 'r'));
} else {
$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");
}
$series = new SimpleXMLElement($series);
$poster = (string) $series->Series->poster;
$poster = $bannerURL . $poster;
file_put_contents("posters/" . $name . ".jpg", fopen($poster, 'r'));
}
}
}
?>