public function processNfoFiles($processImdb = 1, $processTvrage = 1) { $ret = 0; $db = new DB(); $nntp = new Nntp(); $res = $db->queryDirect(sprintf("SELECT rn.*, r.searchname FROM releasenfo rn left outer join releases r ON r.ID = rn.releaseID WHERE rn.nfo IS NULL AND rn.attempts < 5")); if (mysql_num_rows($res) > 0) { if ($this->echooutput) { echo "Processing " . mysql_num_rows($res) . " nfos\n"; } $nntp->doConnect(); while ($arr = mysql_fetch_assoc($res)) { $fetchedBinary = $nntp->getBinary($arr['binaryID'], true); if ($fetchedBinary !== false) { //insert nfo into database $db->query(sprintf("UPDATE releasenfo SET nfo = compress(%s) WHERE ID = %d", $db->escapeString($fetchedBinary), $arr["ID"])); $ret++; $imdbId = $this->parseImdb($fetchedBinary); if ($imdbId !== false) { //update release with imdb id $db->query(sprintf("UPDATE releases SET imdbID = %s WHERE ID = %d", $db->escapeString($imdbId), $arr["releaseID"])); //if set scan for imdb info if ($processImdb == 1) { $movie = new Movie($this->echooutput); //check for existing movie entry $movCheck = $movie->getMovieInfo($imdbId); if ($movCheck === false || isset($movCheck['updateddate']) && time() - strtotime($movCheck['updateddate']) > 2592000) { $movieId = $movie->updateMovieInfo($imdbId); } } } $rageId = $this->parseRageId($fetchedBinary); if ($rageId !== false) { //if set scan for tvrage info if ($processTvrage == 1) { $tvrage = new Tvrage($this->echooutput); $show = $tvrage->parseNameEpSeason($arr['searchname']); if (is_array($show) && $show['name'] != '') { // update release with season, ep, and airdate info (if available) from releasetitle $tvrage->updateEpInfo($show, $arr['releaseID']); $rid = $tvrage->getByRageID($rageId); if (!$rid) { $tvrShow = $tvrage->getRageInfoFromService($rageId); $tvrage->updateRageInfo($rageId, $show, $tvrShow, $arr['releaseID']); } } } } } else { if ($this->echooutput) { echo "NFO download failed - release " . $arr['releaseID'] . " on attempt " . $arr["attempts"]++ . "\n"; } //nfo download failed, increment attempts $db->query(sprintf("UPDATE releasenfo SET attempts = attempts+1 WHERE ID = %d", $arr["ID"])); } if ($ret != 0 && $this->echooutput && $ret % 5 == 0) { echo "-processed " . $ret . " nfos\n"; } } $nntp->doQuit(); } //remove nfo that we cant fetch after 5 attempts $db->query("DELETE FROM releasenfo WHERE nfo IS NULL AND attempts >= 5"); if ($this->echooutput) { echo $ret . " nfo files processed\n"; } return $ret; }