public function download() { $id = $this->route()->getSegment(0); $watcher = $this->_watchers->get($id); $this->result = null; if ($watcher != null) { $season_id = $this->route()->getSegment(1); $episode_id = $this->route()->getSegment(2); $watcher->load(); $ep = null; foreach ($watcher->series()->seasons as $season) { if ($season->num == $season_id) { foreach ($season->episodes as $episode) { if ($episode->num == $episode_id) { $ep = $episode; break; } } break; } } $this->episode = $ep; $newzbin = new Newzbin(); $results = $newzbin->rawSearch("{$watcher->name} {$ep->identifier()} " . $watcher->toNewzbinParams(), $watcher); if ($results != null && is_array($results) && sizeof($results) > 0) { $this->result = $watcher->findSuitableReport($results); $sabnzbd = new SABnzbd(nzbVR::instance()->settings->sabnzbd_address, nzbVR::instance()->settings->sabnzbd_apikey); $sabnzbd->send(array($this->result)); $this->episode->downloaded = true; $this->episode->downloaded_at = time(); $watcher->save(); } } }
public function index() { $query = $this->params()->get("query"); $category = $this->params()->get("category"); $format = $this->params()->get("format"); $source = $this->params()->get("source"); $language = $this->params()->get("language"); //$id = null, $name = null, array $language = null, array $format = null, array $source = null, $category = -1) if ($query != null) { $watcher = new SearchWatcher(null, $query, array($language), array($format), array($source), array($category)); $newzbin = new Newzbin(); $this->results = $newzbin->search($watcher); $this->picnic()->view()->useTemplate("search/results"); } }
public function check() { $term = $this->toSearchTerm(); if ($term != null && $term != "") { $marker = $this->getMarker(); // search newzbin $newzbin = new Newzbin(); $results = $newzbin->search($this, $marker); $result = null; $r = array(); foreach ($results as $report) { if ($report->state == "Report is complete") { $r[] = $report; } } if ($this->toSearchTerm() != $term) { $r2 = $this->check(); if ($r2 != null) { $r = array_merge($r, $r2); } } if ($r != null && sizeof($r) > 0) { //echo "HERE"; //PicnicUtils::dump($r); } return $r; } else { return null; } }