Example #1
0
File: XXX.php Project: EeGgSs/nZEDb
 /**
  * @param array $options Echo to cli / Class instances.
  */
 public function __construct(array $options = [])
 {
     $defaults = ['Echo' => false, 'ReleaseImage' => null, 'Settings' => null];
     $options += $defaults;
     $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings();
     $this->releaseImage = $options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo);
     $this->movieqty = $this->pdo->getSetting('maxxxxprocessed') != '' ? $this->pdo->getSetting('maxxxxprocessed') : 100;
     $this->showPasswords = Releases::showPasswords($this->pdo);
     $this->debug = nZEDb_DEBUG;
     $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI;
     $this->imgSavePath = nZEDb_COVERS . 'xxx' . DS;
     $this->cookie = nZEDb_TMP . 'xxx.cookie';
     if (nZEDb_DEBUG || nZEDb_LOGGING) {
         $this->debug = true;
         try {
             $this->debugging = new Logger();
         } catch (LoggerException $error) {
             $this->_debug = false;
         }
     }
 }
Example #2
0
 /**
  * @param array $options Class instances / Echo to CLI.
  */
 public function __construct(array $options = [])
 {
     $defaults = ['Echo' => false, 'Logger' => null, 'ReleaseImage' => null, 'Settings' => null, 'TMDb' => null];
     $options += $defaults;
     $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings();
     $this->releaseImage = $options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo);
     $this->imdbLanguage = $this->pdo->getSetting('imdblanguage') != '' ? (string) $this->pdo->getSetting('imdblanguage') : 'en';
     $this->tmdb = $options['TMDb'] instanceof \TMDb ? $options['TMDb'] : new \TMDb($this->pdo->getSetting('tmdbkey'), $this->imdbLanguage);
     $this->fanartapikey = $this->pdo->getSetting('fanarttvkey');
     $this->imdburl = $this->pdo->getSetting('imdburl') == 0 ? false : true;
     $this->movieqty = $this->pdo->getSetting('maximdbprocessed') != '' ? $this->pdo->getSetting('maximdbprocessed') : 100;
     $this->searchEngines = true;
     $this->showPasswords = Releases::showPasswords($this->pdo);
     $this->debug = nZEDb_DEBUG;
     $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI && $this->pdo->cli;
     $this->imgSavePath = nZEDb_COVERS . 'movies' . DS;
     $this->service = '';
     $this->catWhere = 'AND categoryid BETWEEN 2000 AND 2999 ';
     if (nZEDb_DEBUG || nZEDb_LOGGING) {
         $this->debug = true;
         try {
             $this->debugging = new Logger();
         } catch (LoggerException $error) {
             $this->_debug = false;
         }
     }
 }
Example #3
0
 /**
  * @param       $cat
  * @param       $start
  * @param       $num
  * @param       $orderby
  * @param array $excludedcats
  *
  * @return array
  */
 public function getMusicRange($cat, $start, $num, $orderby, array $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getMusicOrder($orderby);
     $music = $this->pdo->queryCalc(sprintf("\n\t\t\t\tSELECT SQL_CALC_FOUND_ROWS\n\t\t\t\t\tm.id,\n\t\t\t\t\tGROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id\n\t\t\t\tFROM musicinfo m\n\t\t\t\tLEFT JOIN releases r ON r.musicinfoid = m.id\n\t\t\t\tWHERE r.nzbstatus = 1\n\t\t\t\tAND m.title != ''\n\t\t\t\tAND m.cover = 1\n\t\t\t\tAND r.passwordstatus %s\n\t\t\t\tAND %s %s %s\n\t\t\t\tGROUP BY m.id\n\t\t\t\tORDER BY %s %s %s", Releases::showPasswords($this->pdo), $browseby, $catsrch, $exccatlist, $order[0], $order[1], $start === false ? '' : ' LIMIT ' . $num . ' OFFSET ' . $start), true, nZEDb_CACHE_EXPIRY_MEDIUM);
     $musicIDs = $releaseIDs = false;
     if (is_array($music['result'])) {
         foreach ($music['result'] as $mus => $id) {
             $musicIDs[] = $id['id'];
             $releaseIDs[] = $id['grp_release_id'];
         }
     }
     $sql = sprintf("\n\t\t\tSELECT\n\t\t\t\tGROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id,\n\t\t\t\tGROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount,\n\t\t\t\tGROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview,\n\t\t\t\tGROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password,\n\t\t\t\tGROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid,\n\t\t\t\tGROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid,\n\t\t\t\tGROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname,\n\t\t\t\tGROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name,\n\t\t\t\tGROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate,\n\t\t\t\tGROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size,\n\t\t\t\tGROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts,\n\t\t\t\tGROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments,\n\t\t\t\tGROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs,\n\t\t\t\tGROUP_CONCAT(df.failed ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_failed,\n\t\t\t\tm.*,\n\t\t\t\tr.musicinfoid, r.haspreview,\n\t\t\t\tg.name AS group_name,\n\t\t\t\trn.releaseid AS nfoid\n\t\t\tFROM releases r\n\t\t\tLEFT OUTER JOIN groups g ON g.id = r.group_id\n\t\t\tLEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id\n\t\t\tLEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id\n\t\t\tINNER JOIN musicinfo m ON m.id = r.musicinfoid\n\t\t\tWHERE m.id IN (%s)\n\t\t\tAND r.id IN (%s)\n\t\t\tAND %s\n\t\t\tGROUP BY m.id\n\t\t\tORDER BY %s %s", is_array($musicIDs) ? implode(',', $musicIDs) : -1, is_array($releaseIDs) ? implode(',', $releaseIDs) : -1, $catsrch, $order[0], $order[1]);
     $return = $this->pdo->query($sql, true, nZEDb_CACHE_EXPIRY_MEDIUM);
     if (!empty($return)) {
         $return[0]['_totalcount'] = isset($music['total']) ? $music['total'] : 0;
     }
     return $return;
 }
Example #4
0
 public function getBookRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = '';
     } else {
         $limit = ' LIMIT ' . $num . ' OFFSET ' . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $maxage = '';
     if ($maxage > 0) {
         $maxage = sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxage);
     }
     $exccatlist = '';
     if (count($excludedcats) > 0) {
         $exccatlist = ' AND r.categoryid NOT IN (' . implode(',', $excludedcats) . ')';
     }
     $order = $this->getBookOrder($orderby);
     $sql = sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "boo.*, r.bookinfoid, groups.name AS group_name, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.group_id " . "LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id " . "INNER JOIN bookinfo boo ON boo.id = r.bookinfoid " . "WHERE r.nzbstatus = 1 AND boo.cover = 1 AND boo.title != '' AND " . "r.passwordstatus %s AND %s %s %s %s " . "GROUP BY boo.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $maxage, $exccatlist, $order[0], $order[1]);
     return $this->pdo->query($sql, true, nZEDb_CACHE_EXPIRY_MEDIUM);
 }
Example #5
0
 public function getConsoleRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $num . " OFFSET " . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getConsoleOrder($orderby);
     return $this->pdo->query(sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "con.*, r.consoleinfoid, groups.name AS group_name, genres.title as genre, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.group_id " . "LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id " . "INNER JOIN consoleinfo con ON con.id = r.consoleinfoid " . "INNER JOIN genres ON con.genre_id = genres.id " . "WHERE r.nzbstatus = 1 AND con.title != '' AND " . "r.passwordstatus %s AND %s %s %s " . "GROUP BY con.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $exccatlist, $order[0], $order[1]), true, nZEDb_CACHE_EXPIRY_MEDIUM);
 }