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; }
/** * @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; }
public static function determineQuality($fileName) { $QS = SerieGUI::getQualities(); for ($i = 2; $i < count($QS); $i++) { if (strpos($fileName, $QS[$i]) !== false) { return $QS[$i]; } } return $QS[1]; }