Esempio 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;
 }
Esempio n. 2
0
 /**
  * no guessing - if value seems reasonable or not - required
  */
 public function migrateNonGuessableData($rawArray)
 {
     $t = new \Slimpd\Track();
     $t->setId($rawArray['id']);
     $t->setRelativePath($rawArray['relativePath']);
     $t->setRelativePathHash($rawArray['relativePathHash']);
     $t->setDirectoryPathHash($rawArray['relativeDirectoryPathHash']);
     $t->setFingerprint($rawArray['fingerprint']);
     $t->setMimeType($rawArray['mimeType']);
     $t->setFilesize($rawArray['filesize']);
     $t->setFilemtime($rawArray['filemtime']);
     $t->setMiliseconds(round($rawArray['miliseconds'] * 1000));
     $t->setAudioDataformat($rawArray['audioDataformat']);
     $t->setAudioCompressionRatio($rawArray['audioCompressionRatio']);
     $t->setAudioEncoder($rawArray['audioEncoder'] ? $rawArray['audioEncoder'] : 'Unknown encoder');
     if ($rawArray['audioLossless']) {
         $t->setAudioLossless($rawArray['audioLossless']);
         if ($rawArray['audioCompressionRatio'] == 1) {
             $t->setAudioProfile('Losless');
         } else {
             $t->setAudioProfile('Losless compression');
         }
     }
     $t->setAudioBitrate(round($rawArray['audioBitrate']));
     // integer in database
     if (!$t->getAudioProfile()) {
         $t->setAudioProfile($rawArray['audioBitrateMode'] . " " . round($t->getAudioBitrate() / 1000, 1) . " kbps");
     }
     $t->setAudioBitsPerSample($rawArray['audioBitsPerSample'] ? $rawArray['audioBitsPerSample'] : 16);
     $t->setAudioSampleRate($rawArray['audioSampleRate'] ? $rawArray['audioSampleRate'] : 44100);
     $t->setAudioChannels($rawArray['audioChannels'] ? $rawArray['audioChannels'] : 2);
     $t->setVideoDataformat($rawArray['videoDataformat']);
     $t->setVideoCodec($rawArray['videoCodec']);
     $t->setVideoResolutionX($rawArray['videoResolutionX']);
     $t->setVideoResolutionY($rawArray['videoResolutionY']);
     $t->setVideoFramerate($rawArray['videoFramerate']);
     $t->setImportStatus($rawArray['importStatus']);
     $t->setLastScan($rawArray['lastScan']);
     $t->setError($rawArray['error']);
     $t->setDr($rawArray['dynamicRange']);
     return $t;
 }
Esempio n. 3
0
        } else {
            if (is_numeric($app->request->get('item')) === TRUE) {
                $search = array('id' => (int) $app->request->get('item'));
            } else {
                $search = array('relativePathHash' => getFilePathHash($app->request->get('item')));
                $itemRelativePath = $app->request->get('item');
            }
            $config['item'] = \Slimpd\Track::getInstanceByAttributes($search);
        }
        if (is_null($config['item']) === FALSE && $config['item']->getId() > 0) {
            $config['renderitems'] = array('genres' => \Slimpd\Genre::getInstancesForRendering($config['item']), 'labels' => \Slimpd\Label::getInstancesForRendering($config['item']), 'artists' => \Slimpd\Artist::getInstancesForRendering($config['item']), 'albums' => \Slimpd\Album::getInstancesForRendering($config['item']));
            $itemRelativePath = $config['item']->getRelativePath();
        } else {
            // playing track has not been imported in slimpd database yet...
            // so we are not able to get any renderitems
            $item = new \Slimpd\Track();
            $item->setRelativePath($itemRelativePath);
            $config['item'] = $item;
        }
        // TODO: remove external liking as soon we have implemented a proper functionality
        $config['temp_likerurl'] = 'http://ixwax/filesystem/plusone?f=' . urlencode($config['mpd']['alternative_musicdir'] . $itemRelativePath);
        $app->render('modules/' . $markupSnippet . '.twig', $config);
        $app->stop();
    });
}
// predefined album-image sizes
foreach (array(50, 100, 300, 1000) as $imagesize) {
    $app->get('/image-' . $imagesize . '/album/:itemId', function ($itemId) use($app, $config, $imagesize) {
        $image = \Slimpd\Bitmap::getInstanceByAttributes(array('albumId' => $itemId), 'filesize DESC');
        $image = $image === NULL ? \Slimpd\Bitmap::getFallbackImage() : $image;
        $image->dump($imagesize);