示例#1
0
function checkTvImages($pdo, $tvrage)
{
    $text = new Text();
    $images = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tvrage->imgSavePath), RecursiveIteratorIterator::SELF_FIRST);
    if ($images instanceof \Traversable) {
        $imgCount = iterator_count($images);
        echo PHP_EOL . $pdo->log->header("Matching " . number_format($imgCount) . " files to their RageIDs and setting hascover.") . PHP_EOL;
        $checkCnt = $notReqdCnt = $badRageCnt = 0;
        foreach ($images as $file) {
            $rightCut = $text->cutStringUsingLast('/', $file, "right", false);
            $leftCut = $text->cutStringUsingLast('.', $rightCut, "left", false);
            $check = $pdo->queryOneRow(sprintf("SELECT id, hascover\n\t\t\t\t\t\t\t\t\tFROM tvrage_titles\n\t\t\t\t\t\t\t\t\tWHERE rageid = %d", $leftCut));
            if ($check) {
                if ($check['hascover'] == 0) {
                    $pdo->queryExec(sprintf("UPDATE tvrage_titles\n\t\t\t\t\t\t\t\t\t\tSET hascover = 1\n\t\t\t\t\t\t\t\t\t\tWHERE id = %d", $check['id']));
                    $checkCnt++;
                } else {
                    $notReqdCnt++;
                }
            } else {
                $missingRageCnt++;
            }
        }
    }
    echo PHP_EOL . $pdo->log->primary("Updated " . number_format($checkCnt) . " RageIDs. " . number_format($notReqdCnt) . " were already set and " . number_format($missingRageCnt) . " images did not have matching RageIDs in the database.") . PHP_EOL;
}
示例#2
0
文件: NameFixer.php 项目: zetas/nZEDb
 /**
  * Cleans file names for PreDB Match
  */
 protected function _cleanMatchFiles($fileName = '')
 {
     // first strip all non-printing chars  from filename
     $this->_fileName = $this->text->stripNonPrintingChars($fileName);
     if (strlen($this->_fileName) !== false && strlen($this->_fileName) > 0 && strpos($this->_fileName, '.') !== 0) {
         switch (true) {
             case strpos($this->_fileName, '.') !== false:
                 //some filenames start with a period that ends up creating bad matches so we don't process them
                 $this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false);
                 continue;
                 //if filename has a .part001, send it back to the function to cut the next period
             //if filename has a .part001, send it back to the function to cut the next period
             case preg_match('/\\.part\\d+$/', $this->_fileName):
                 $this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false);
                 continue;
                 //if filename has a .vol001, send it back to the function to cut the next period
             //if filename has a .vol001, send it back to the function to cut the next period
             case preg_match('/\\.vol\\d+(\\+\\d+)?$/', $this->_fileName):
                 $this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false);
                 continue;
                 //if filename contains a slash, cut the string and keep string to the right of the last slash to remove dir
             //if filename contains a slash, cut the string and keep string to the right of the last slash to remove dir
             case strpos($this->_fileName, '\\') !== false:
                 $this->_fileName = $this->text->cutStringUsingLast('\\', $this->_fileName, "right", false);
                 continue;
                 // A lot of obscured releases have one NFO file properly named with a track number (Audio) at the front of it
                 // This will strip out the track and match it to its pre title
             // A lot of obscured releases have one NFO file properly named with a track number (Audio) at the front of it
             // This will strip out the track and match it to its pre title
             case preg_match('/^\\d{2}-/', $this->_fileName):
                 $this->_fileName = preg_replace('/^\\d{2}-/', '', $this->_fileName);
         }
         return trim($this->_fileName);
     }
 }