예제 #1
0
 public function renameFile($originalFile)
 {
     $S = new Serie($this->A("SerieID"));
     if (Util::isWindowsHost()) {
         $originalFile = utf8_decode($originalFile);
     }
     if (rename($S->A("dir") . "/" . $originalFile, $S->A("dir") . "/" . $this->getNewFileName($S, $this->getSuffix($originalFile)))) {
         echo "message:'renaming successfull'";
     }
 }
예제 #2
0
 public function download(RSSFilter $RSF, $filename, $page, $targetFileName, Serie $Serie)
 {
     $usableHosts = $this->getAvailableHosts($RSF);
     if (count($usableHosts) == 0) {
         return array("You did not select any hosts to download from", "");
     }
     $JD = new JD($RSF->A("RSSFilterJDID"));
     foreach (self::$links[$page] as $link) {
         $url = parse_url($link);
         #print_r($url);
         #echo $link."\n";
         $found = false;
         foreach ($usableHosts as $host) {
             if (stripos($url["host"], $host) === false) {
                 continue;
             }
             #echo Serie::determineQuality($link);
             #echo $Serie->A("quality");
             if (Serie::determineQuality($link) != SerieGUI::getQualities($Serie->A("quality"))) {
                 continue;
             }
             $found = $link;
         }
         if (!$found) {
             continue;
         }
         try {
             $JD->download($link, $filename, $targetFileName, $Serie);
         } catch (Exception $e) {
         }
         break;
     }
     return true;
 }
예제 #3
0
 public function fileExists($S = null)
 {
     if ($S == null) {
         $S = new Serie($this->A("SerieID"));
     }
     return file_exists($S->A("dir") . "/" . $this->getNewFileName($S, $this->getExistingSuffix($S)));
     #return (file_exists($S->A("dir")."/".$this->getNewFileName($S, "avi")) OR file_exists($S->A("dir")."/".$this->getNewFileName($S, "mkv")) OR file_exists($S->A("dir")."/".$this->getNewFileName($S, "divx")));
 }
예제 #4
0
 function __construct()
 {
     parent::__construct();
     $bps = $this->getMyBPSData();
     $S = new Serie($bps["SerieID"]);
     $F = new mFile();
     $F->setDir($S->A("dir"), true);
     mFolgeGUI::$Serie = $S;
     $E = array();
     while ($t = $F->getNextEntry()) {
         if (!$t->A("FileIsDir")) {
             $newFilename = $t->A("FileName");
             if (Util::isWindowsHost()) {
                 $newFilename = utf8_encode($newFilename);
             }
             $E[] = $newFilename;
         }
     }
     mFolgeGUI::$files = $E;
     mFolgeGUI::$found = array();
 }
예제 #5
0
 function newEpisodes()
 {
     $html = "<h1>Demnächst</h1>";
     $AC = anyC::get("Folge");
     $AC->addAssocV3("UNIX_TIMESTAMP(STR_TO_DATE(airDate, '%Y-%m-%d')) + 120", ">=", mktime(0, 0, 1));
     $AC->addAssocV3("UNIX_TIMESTAMP(STR_TO_DATE(airDate, '%Y-%m-%d'))", "<=", time() + 3600 * 24 * 6);
     $AC->addAssocV3("RSSFilterID", ">", "0");
     $AC->addJoinV3("Serie", "SerieID", "=", "SerieID");
     $AC->addOrderV3("UNIX_TIMESTAMP(STR_TO_DATE(airDate, '%Y-%m-%d 18:00'))", "ASC");
     $i = 0;
     $lastAD = null;
     while ($S = $AC->getNextEntry()) {
         if ($lastAD != $S->A("airDate")) {
             if ($lastAD !== null) {
                 $html .= "</div>";
             }
             $date = strtotime($S->A("airDate"));
             $html .= "<div class=\"comingUp\" style=\"box-sizing:border-box;" . ($i % 2 == 0 ? "background-color: #F2F2F2;" : "") . "padding:10px;display:inline-block;width:calc(100% / 7);vertical-align:top;\"><h2 style=\"margin-top:0;padding-top:0;\">" . mb_substr(Util::CLWeekdayName(date("w", $date)), 0, 2) . ", " . Util::CLDateParser($date) . "</h2>";
             $i++;
         }
         $html .= $S->A("name") . " <span style=\"color:grey;\">S" . ($S->A("season") < 10 ? "0" : "") . $S->A("season") . "E" . ($S->A("episode") < 10 ? "0" : "") . $S->A("episode") . "</span><br>";
         $lastAD = $S->A("airDate");
     }
     $html .= "</div>" . OnEvent::script("g.sameHeight('.comingUp');");
     $html .= "<h1>Neue Folgen</h1>";
     $AC = anyC::get("JDownload");
     $AC->addAssocV3("JDownloadDate", ">", time() - 3600 * 24 * 7);
     $AC->addOrderV3("JDownloadDate", "DESC");
     $AC->addAssocV3("JDownloadSerieID", "!=", "0");
     $AC->addJoinV3("Serie", "JDownloadSerieID", "=", "SerieID");
     while ($D = $AC->getNextEntry()) {
         if ($D->A("JDownloadSerieID") != "0" and $D->A("cover") != "" and trim($D->A("coverThumb")) == "") {
             $S = new Serie($D->A("JDownloadSerieID"));
             $S->changeA("coverThumb", DBImageGUI::stringifyDataS("image/png", DBImageGUI::getData($S->A("cover")), 150, 220));
             $S->saveMe(true, false);
             $D->changeA("coverThumb", $S->A("coverThumb"));
         }
         preg_match("/S([0-9]+)E([0-9]+)/", $D->A("JDownloadRenameto"), $matches);
         $ACF = anyC::get("Folge", "SerieID", $D->A("SerieID"));
         $ACF->addAssocV3("season", "=", $matches[1]);
         $ACF->addAssocV3("episode", "=", $matches[2]);
         $ACF->setLimitV3(1);
         $F = $ACF->getNextEntry();
         $B = new Button("Abspielen", "play", "touch");
         $B->onclick("parent.UPnP.search('" . Util::makeFilename(str_replace(" ", ".", $D->A("JDownloadRenameto"))) . "');");
         $html .= "\n\t\t\t<div style=\"display:inline-block;width:33%;margin-bottom:2%;vertical-align:top;\">\n\t\t\t\t<div style=\"margin-right:20px;float:left;width:150px;\">\n\t\t\t\t\t<img style=\"width:150px;height:220px;margin-bottom:5px;\" src=\"./index.php?D=trinityDB/Serien&M=getCover&P0=" . $D->A("SerieID") . "\" />\n\t\t\t\t\t\t{$B}\n\t\t\t\t</div>\n\t\t\t\t<h2 style=\"margin-top:0px;padding-top:0px;\">" . $D->A("JDownloadRenameto") . "</h2>\n\t\t\t\t<p style=\"color:grey;\">" . ($F != null ? $F->A("description") : "Keine Beschreibung") . " <small>" . Util::CLDateParser($D->A("JDownloadDate")) . "</small></p>\n\t\t\t</div>";
     }
     return $html;
 }
예제 #6
0
 public static function parserSerie($w)
 {
     $Serie = new Serie($w);
     return $Serie->A("name");
 }
예제 #7
0
 /**
  * @param Serie $Series
  * @param Folge[] $Episodes 
  */
 public function filterFor(Serie $Series, $Episodes)
 {
     $filtered = array();
     $foundEpisodes = array();
     $this->loadFeed();
     $Adapter = $this->getFeedAdapter();
     $xml = RSSFilter::$feeds[$this->A("RSSFilterFeed")];
     if ($xml === "null") {
         return $filtered;
     }
     foreach ($xml->channel->item as $v) {
         #print_r($v);
         foreach ($Episodes as $E) {
             $title = $v->title . "";
             if (strpos($title, "[ENGLISCH]") !== false or strpos($title, "[DEUTSCH]") !== false) {
                 if ($Series->A("sprache") == "en" and strpos($title, "[ENGLISCH]") === false) {
                     continue;
                 }
                 if ($Series->A("sprache") == "de" and strpos($title, "[DEUTSCH]") === false) {
                     continue;
                 }
             }
             $ts01e01 = stripos($title, "S" . ($E->A("season") < 10 ? "0" : "") . $E->A("season") . "E" . ($E->A("episode") < 10 ? "0" : "") . $E->A("episode"));
             $t01x01 = stripos($title, $E->A("season") . "×" . ($E->A("episode") < 10 ? "0" : "") . $E->A("episode"));
             $t01ix01 = stripos($title, $E->A("season") . "x" . ($E->A("episode") < 10 ? "0" : "") . $E->A("episode"));
             if ($ts01e01 === false and $t01x01 === false and $t01ix01 === false) {
                 continue;
             }
             if (strpos(strtolower($title), strtolower(str_replace(" ", ".", $Series->A("name")))) === false and strpos(strtolower($title), strtolower($Series->A("name"))) === false and ($Series->A("altFeedName1") == "" or strpos(strtolower($title), strtolower(str_replace(" ", ".", $Series->A("altFeedName1")))) === false)) {
                 continue;
             }
             if ($Series->A("quality") > 1 and strpos(strtolower($title), strtolower(SerieGUI::getQualities($Series->A("quality")))) === false) {
                 continue;
             }
             $continue = false;
             if ($Series->A("quality") == "1") {
                 foreach (SerieGUI::getQualities() as $k => $q) {
                     if ($k < 2) {
                         continue;
                     }
                     if (strpos(strtolower($title), strtolower($q)) !== false) {
                         $continue = true;
                     }
                 }
             }
             if ($continue) {
                 continue;
             }
             if (isset($foundEpisodes[$E->getID()])) {
                 continue;
             }
             $foundEpisodes[$E->getID()] = true;
             $filtered[] = array("title" => $title, "link" => $v->link . "", "pubDate" => $v->pubDate . "", "description" => $v->description . "", "fileName" => $Adapter->filterFilename($Series, $v), "season" => ($E->A("season") < 10 ? "0" : "") . $E->A("season"), "episode" => ($E->A("episode") < 10 ? "0" : "") . $E->A("episode"));
             #print_r($filtered);
             #echo $title."<br />";
         }
     }
     return $filtered;
 }
예제 #8
0
 public function download(Serie $S, $echo = false)
 {
     $tab = new HTMLTable(1);
     $mirrorPath = $this->getMirror();
     $tab->addRow("Retrieving mirror list... using {$mirrorPath}");
     $serverTime = $this->getServerTime();
     $tab->addRow("Retrieving server time... {$serverTime}");
     $S->changeA("lastupdate", $serverTime);
     if ($S->A("siteID") == 0) {
         $tab->addRow("Retrieving series information...");
         $data = file_get_contents("{$mirrorPath}/api/GetSeries.php?seriesname=" . urlencode($S->A("name")) . "&language=" . $S->A("sprache"));
         if ($data === false) {
             throw new Exception("No data from {$mirrorPath}/api/GetSeries.php?seriesname=" . urlencode($S->A("name")) . "&language=" . $S->A("sprache"));
         }
         #die("DATA: $data");
         $seriesInfo = new SimpleXMLElement($data, null, false);
         $seriesID = $seriesInfo->Series->seriesid;
         $S->changeA("siteID", $seriesID);
         #$S->changeA("description", $seriesInfo->Series->Overview);
     } else {
         $seriesID = $S->A("siteID");
     }
     $tempFile = Util::getTempFilename("SerieID" . $S->getID(), "zip");
     $tab->addRow("Downloading episodes information...");
     $SZip = "{$mirrorPath}/api/{$this->apiKey}/series/{$seriesID}/all/" . $S->A("sprache") . ".zip";
     if (!copy($SZip, $tempFile)) {
         Red::errorD("The download of {$SZip} failed!");
     }
     try {
         $zip = new ZipArchive();
         if ($zip->open($tempFile) === TRUE) {
             $zip->extractTo(dirname($tempFile) . "/SerieID" . $S->getID());
             $zip->close();
             $tab->addRow("Extracting data...");
         } else {
             throw new ClassNotFoundException("");
         }
     } catch (ClassNotFoundException $e) {
         if (!Util::isWindowsHost()) {
             $commandUnzip = "unzip -o {$tempFile} -d SerieID" . $S->getID();
         } else {
             $commandUnzip = Util::getRootPath() . "trinityDB/Serien/unzip.exe -o {$tempFile} -d SerieID" . $S->getID();
         }
         $tab->addRow("Extracting data...<br />{$commandUnzip}");
         $sc = new SystemCommand();
         $sc->setCommand("cd " . dirname($tempFile) . " && {$commandUnzip}");
         $sc->execute();
     }
     $e = 0;
     $u = 0;
     $file = dirname($tempFile) . "/SerieID" . $S->getID() . "/" . $S->A("sprache") . ".xml";
     if (!file_exists($file)) {
         Red::errorD("Could not find the expected file {$file}. Please check if it was properly extracted from {$tempFile}.");
     }
     $episodesList = new SimpleXMLElement(file_get_contents($file));
     $status = $episodesList->Series->Status;
     $S->changeA("description", $episodesList->Series->Overview);
     $S->changeA("status", $status);
     $S->changeA("genre", $episodesList->Series->Genre);
     foreach ($episodesList->Episode as $k => $v) {
         $AC = anyC::get("Folge", "SerieID", $S->getID());
         $AC->addAssocV3("season", "=", $v->SeasonNumber);
         $AC->addAssocV3("episode", "=", $v->EpisodeNumber);
         $AC->lCV3();
         if ($AC->numLoaded() > 1) {
             while ($F = $AC->getNextEntry()) {
                 $F->deleteMe();
             }
         }
         $F = new Factory("Folge");
         $F->sA("SerieID", $S->getID());
         $F->sA("season", $v->SeasonNumber);
         $F->sA("episode", $v->EpisodeNumber);
         if ($E = $F->exists(true)) {
             if ($v->lastupdated == $E->A("lastupdate")) {
                 continue;
             }
             $E->changeA("name", $v->EpisodeName);
             $E->changeA("airDate", $v->FirstAired);
             $E->changeA("lastupdate", $v->lastupdated);
             $E->changeA("description", $v->Overview);
             $E->saveMe(true, false);
             $u++;
             continue;
         }
         $F->sA("episodeID", $v->id);
         $F->sA("name", $v->EpisodeName);
         $F->sA("airDate", $v->FirstAired);
         $F->sA("lastupdate", $v->lastupdated);
         $F->sA("description", $v->Overview);
         $F->sA("wanted", "1");
         $F->store(true, false);
         $e++;
     }
     $tab->addRow("Loaded {$e} episodes");
     $tab->addRow("Updated {$u} episodes");
     if (mUserdata::getGlobalSettingValue("trinityDBdlCover", "0") == "1") {
         $bannerList = new SimpleXMLElement(dirname($tempFile) . "/SerieID" . $S->getID() . "/banners.xml", null, true);
         foreach ($bannerList as $banner) {
             if ($banner->BannerType . "" == "poster") {
                 #echo $banner->BannerPath."";
                 $cover = file_get_contents("http://www.thetvdb.com/banners/" . $banner->BannerPath);
                 $temp = Util::getTempFilename("cover", "jpg");
                 file_put_contents($temp, $cover);
                 if ($S->A("dir") != "" and file_exists($S->A("dir"))) {
                     file_put_contents($S->A("dir") . "/Folder.jpg", $cover);
                 }
                 $S->changeA("cover", DBImageGUI::stringifyS("image/jpg", $temp));
                 $S->changeA("coverThumb", DBImageGUI::stringifyS("image/png", $temp, 150, 220));
                 #$S->saveMe();
                 unlink($temp);
                 $tab->addRow("Downloaded cover");
                 break;
             }
         }
     }
     $S->saveMe(true, false);
     if ($echo) {
         echo $tab;
     }
 }