Ejemplo n.º 1
0
 public function extractAllMp3FingerPrints($forceAllAlbums = FALSE)
 {
     $app = \Slim\Slim::getInstance();
     $this->jobPhase = 10;
     if ($app->config['modules']['enable_fingerprints'] !== '1') {
         return;
     }
     // reset phase
     // UPDATE rawtagdata SET fingerprint="" WHERE audioDataFormat="mp3"
     $this->beginJob(array('currentItem' => "fetching mp3 files with missing fingerprint attribute"), __FUNCTION__);
     $query = "\n\t\t\tSELECT count(id) AS itemCountTotal\n\t\t\tFROM rawtagdata\n\t\t\tWHERE audioDataFormat='mp3' AND fingerprint=''";
     $this->itemCountTotal = (int) $app->db->query($query)->fetch_assoc()['itemCountTotal'];
     $query = "\n\t\t\tSELECT id, relativePath\n\t\t\tFROM rawtagdata\n\t\t\tWHERE audioDataFormat='mp3' AND fingerprint=''";
     $result = $app->db->query($query);
     while ($record = $result->fetch_assoc()) {
         $this->itemCountChecked++;
         $this->updateJob(array('currentItem' => 'albumId: ' . $record['relativePath']));
         $this->itemCountProcessed++;
         $fullPath = $app->config['mpd']['musicdir'] . $record['relativePath'];
         if (is_file($fullPath) == FALSE || is_readable($fullPath) === FALSE) {
             cliLog("ERROR: fileaccess " . $record['relativePath'], 1, 'red');
             continue;
         }
         if ($fp = self::extractAudioFingerprint($fullPath)) {
             $i = new \Slimpd\Rawtagdata();
             $i->setId($record['id']);
             $i->setFingerprint($fp);
             $i->update();
             $i = new \Slimpd\Track();
             $i->setId($record['id']);
             $i->setFingerprint($fp);
             $i->update();
             cliLog("fingerprint: " . $fp . " for " . $record['relativePath'], 3);
         } else {
             cliLog("ERROR: regex fingerprint result " . $record['relativePath'], 1, 'red');
             continue;
         }
     }
     $this->finishJob(array(), __FUNCTION__);
     return;
 }