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 sendID() { $id = $this->route()->getSegment(0); if ($id != null) { $sabnzbd = new SABnzbd(); $sabnzbd->sendID($id); $this->state = "OK"; } else { $this->state = "Fail"; $this->message = "You must provide an ID."; } }
<?php require_once WWW_DIR . "/lib/sabnzbd.php"; require_once WWW_DIR . "/lib/nzbget.php"; if (!$users->isLoggedIn()) { $page->show403(); } $sab = new SABnzbd($page); $nzbget = new NZBGet($page); if (empty($sab->url) && empty($sab->apikey) && empty($nzbget->url) && empty($nzbget->username)) { $page->show404(); } $output = ""; $reqtype = isset($_REQUEST["type"]) ? $_REQUEST["type"] : "queue"; switch ($reqtype) { case "queue": $json = $sab->getQueue(); if ($json !== false) { $obj = json_decode($json); $queue = $obj->{'jobs'}; $count = 1; $speed = $obj->{'speed'}; $queued = round($obj->{'mbleft'}, 2) . "MB / " . round($obj->{'mb'}, 2) . "MB"; $status = ucwords(strtolower($obj->{'state'})); $output .= "<p><b>Download speed:</b> " . $speed . "B/s - <b>Queued:</b> " . $queued . " - <b>Status:</b> " . $status . "</p>"; if (count($queue) > 0) { $output .= "<table class=\"data highlight\">"; $output .= "<tr>\r\n <th></th>\r\n <th>Name</th>\r\n <th style='width:80px;'>size</th>\r\n <th style='width:80px;'>left</th>\r\n <th style='width:50px;'>%</th>\r\n <th>time left</th>\r\n <th></th>\r\n </tr>"; foreach ($queue as $item) { if (strpos($item->{'filename'}, "fetch NZB") > 0) { } else {
<?php require_once WWW_DIR . "/lib/sabnzbd.php"; if (!$users->isLoggedIn()) { $page->show403(); } if (empty($_GET["id"])) { $page->show404(); } $sab = new SABnzbd($page); if (empty($sab->url)) { $page->show404(); } if (empty($sab->apikey)) { $page->show404(); } $guid = $_GET["id"]; $sab->sendToSab($guid);
<?php require_once WWW_DIR . "/lib/sabnzbd.php"; require_once WWW_DIR . "/lib/nzbget.php"; if (!$users->isLoggedIn()) { $page->show403(); } $sab = new SABnzbd($page); $nzbget = new NZBGet($page); if (empty($sab->url) && empty($sab->apikey) && empty($nzbget->url) && empty($nzbget->username)) { $page->show404(); } if (isset($_REQUEST["del"])) { $sab->delFromQueue($_REQUEST['del']); } if (isset($_REQUEST["nzbgetdel"])) { $nzbget->delFromQueue($_REQUEST['nzbgetdel']); } $page->smarty->assign('sabserver', $sab->url); $page->smarty->assign('nzbgetserver', $nzbget->url); $page->smarty->assign('showsabhistory', $sab->apikeytype == SABnzbd::API_TYPE_FULL); $page->title = "Your Download Queue"; $page->meta_title = "View Download Queue"; $page->meta_keywords = "view,download,queue"; $page->meta_description = "View Download Queue"; $page->content = $page->smarty->fetch('viewqueue.tpl'); $page->render();
<?php $rc = new ReleaseComments(); $sab = new SABnzbd($page); $nzbget = new NZBGet($page); if (!$page->users->isLoggedIn()) { $page->show403(); } $userID = 0; if (isset($_GET["id"])) { $userID = $_GET["id"] + 0; } elseif (isset($_GET["name"])) { $res = $page->users->getByUsername($_GET["name"]); if ($res) { $userID = $res["id"]; } } else { $userID = $page->users->currentUserId(); } $privileged = $page->users->isAdmin($userID) || $page->users->isModerator($userID) ? true : false; $privateProfiles = $page->settings->getSetting('privateprofiles') == 1 ? true : false; $publicView = false; if (!$privateProfiles || $privileged) { $altID = isset($_GET['id']) && $_GET['id'] >= 0 ? (int) $_GET['id'] : false; $altUsername = isset($_GET['name']) && strlen($_GET['name']) > 0 ? $_GET['name'] : false; // If both 'id' and 'name' are specified, 'id' should take precedence. if ($altID === false && $altUsername !== false) { $user = $page->users->getByUsername($altUsername); if ($user) { $altID = $user['id']; }
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } $sab = new SABnzbd($page); $output = ""; $json = $sab->getQueue(); if ($json !== false) { $obj = json_decode($json); $queue = $obj->{'jobs'}; $count = 1; $output .= "<div class='container text-center' style='display:block;'>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Speed:</b><br /> " . $obj->{'speed'} . "B/s </div>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Queued:</b><br /> " . round($obj->{'mbleft'}, 2) . "MB / " . round($obj->{'mb'}, 2) . "MB" . " </div>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Status:</b><br /> " . ucwords(strtolower($obj->{'state'})) . " </div>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Free (temp):</b><br /> " . round($obj->{'diskspace1'}) . "GB </div>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Free Space:</b><br /> " . round($obj->{'diskspace2'}) . "GB</div>\n\t\t\t<div style='width:16.666666667%;float:left;'><b>Stats:</b><br /> " . preg_replace('/\\s+\\|\\s+| /', ',', $obj->{'loadavg'}) . " </div>\n\t\t</div>"; if (count($queue) > 0) { $output .= "<table class='table table-striped table-condensed table-highlight data'>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr >\n\t\t\t\t\t\t<th style='width=10px;text-align:center;'>#</th>\n\t\t\t\t\t\t<th style='text-align:left;'>Name</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Size</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Left</th>\n\t\t\t\t\t\t<th style='width:50px;text-align:center;'>Done</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'>Time Left</th>\n\t\t\t\t\t\t<th style='width:50px;text-align:center;'>Delete</th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'><a href='?pall'>Pause all</a></th>\n\t\t\t\t\t\t<th style='width:80px;text-align:center;'><a href='?rall'>Resume all</a></th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>"; foreach ($queue as $item) { if (strpos($item->{'filename'}, "fetch NZB") === false) { $output .= "<tr>" . "<td style='text-align:center;width:10px'>" . $count . "</td>" . "<td style='text-align:left;'>" . $item->{'filename'} . "</td>" . "<td style='text-align:center;'>" . round($item->{'mb'}, 2) . " MB</td>" . "<td style='text-align:center;'>" . round($item->{'mbleft'}, 2) . " MB</td>" . "<td style='text-align:center;'>" . ($item->{'mb'} == 0 ? 0 : round(100 - $item->{'mbleft'} / $item->{'mb'} * 100)) . "%</td>" . "<td style='text-align:center;'>" . $item->{'timeleft'} . "</td>" . "<td style='text-align:center;'><a onclick=\"return confirm('Are you sure?');\" href='?del=" . $item->{'id'} . "'>Delete</a></td>" . "<td style='text-align:center;'><a href='?pause=" . $item->{'id'} . "'>Pause</a></td>" . "<td style='text-align:center;'><a href='?resume=" . $item->{'id'} . "'>Resume</a></td>" . "</tr>"; $count++; } } $output .= "</tbody>\n\t\t\t</table>"; } else { $output .= "<br /><br /><p style='text-align:center;'>The queue is currently empty.</p>"; } } else { $output .= "<p style='text-align:center;'>Error retrieving queue.</p>"; } print $output;
public function check() { $this->results = array(); $type = $this->params()->get("type"); $id = null; if (sizeof($this->route()->segments()) == 1) { $id = $this->route()->getSegment(0); } $this->_watchers->last_benchmark = new WatcherBenchmark(); $this->_watchers->last_benchmark->mark("start"); foreach ($this->_watchers->watchers as $watcher) { if ($watcher != null && ($type == null || $type == "movies" && $watcher instanceof MovieWatcher || $type == "series" && $watcher instanceof SeriesWatcher || $type == "search" && $watcher instanceof SearchWatcher) && ($id == null || $watcher->id == $id)) { $this->checkWatcher($watcher); } } if ($this->results != null && sizeof($this->results) > 0) { $sabnzbd = new SABnzbd(nzbVR::instance()->settings->sabnzbd_address, nzbVR::instance()->settings->sabnzbd_apikey); $sabnzbd->send($this->results); } //$notifiers = new Notifiers(); //foreach ($this->results as $result) { // $notifiers->notification("Sent '{$result->name}' report to SABnzbd+", "Report found"); //} $notifiers = null; $this->_watchers->last_benchmark->downloads = sizeof($this->results); $this->_watchers->last_benchmark->mark("end"); $this->_watchers->save(); if ($this->picnic()->router()->outputType() == "html") { //$this->redirect("index"); } }
<?php require_once WWW_DIR . "/lib/releasecomments.php"; require_once WWW_DIR . "/lib/category.php"; require_once WWW_DIR . "/lib/sabnzbd.php"; $rc = new ReleaseComments(); $sab = new SABnzbd($page); if (!$users->isLoggedIn()) { $page->show403(); } $userid = 0; if (isset($_GET["id"])) { $userid = $_GET["id"] + 0; } elseif (isset($_GET["name"])) { $res = $users->getByUsername($_GET["name"]); if ($res) { $userid = $res["ID"]; } } else { $userid = $users->currentUserId(); } $data = $users->getById($userid); if (!$data) { $page->show404(); } $invitedby = ''; if ($data["invitedby"] != "") { $invitedby = $users->getById($data["invitedby"]); } $page->smarty->assign('userinvitedby', $invitedby); $page->smarty->assign('user', $data);
<?php require_once WWW_DIR . "/lib/category.php"; require_once WWW_DIR . "/lib/sabnzbd.php"; $category = new Category(); $sab = new SABnzbd($page); if (!$users->isLoggedIn()) { $page->show403(); } $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; $userid = $users->currentUserId(); $data = $users->getById($userid); if (!$data) { $page->show404(); } $errorStr = ''; switch ($action) { case 'newapikey': $users->updateRssKey($userid); header("Location: profileedit"); break; case 'clearcookies': $sab->unsetCookie(); header("Location: profileedit"); break; case 'submit': $data["email"] = $_POST['email']; if ($_POST['password'] != "" && $_POST['password'] != $_POST['confirmpassword']) { $errorStr = "Password Mismatch"; } else { if ($_POST['password'] != "" && !$users->isValidPassword($_POST['password'])) {
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } if (empty($_GET["id"])) { $page->show404(); } $user = $page->users->getById($page->users->currentUserId()); if ($user['queuetype'] != 2) { $sab = new SABnzbd($page); if (empty($sab->url)) { $page->show404(); } if (empty($sab->apikey)) { $page->show404(); } $sab->sendToSab($_GET["id"]); } elseif ($user['queuetype'] == 2) { $nzbget = new NZBGet($page); $nzbget->sendURLToNZBGet($_GET['id']); }