| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- require('functions.php');
- $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");
- }
- $series = new SimpleXMLElement($series);
- $poster = (string) $series->Series->poster;
- $poster = $bannerURL . $poster;
- file_put_contents("posters/" . $seriesName . ".jpg", fopen($poster, 'r'));
- echo "Done.";
- } else {
- $list = scandir("/media/Serien");
- $list = array_diff($list, array('.', '..'));
- foreach($list as $name) {
- 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");
- }
- $series = new SimpleXMLElement($series);
- $poster = (string) $series->Series->poster;
- $poster = $bannerURL . $poster;
- file_put_contents("posters/" . $name . ".jpg", fopen($poster, 'r'));
- }
- }
- }
- ?>
|