cc-4105: removed naive replaygain again. added micro optimization to Insert into cc_files
This commit is contained in:
parent
91145a3f16
commit
e98eda144a
|
@ -456,8 +456,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
$this->view->watched_dirs = $watchedDirsPath;
|
$this->view->watched_dirs = $watchedDirsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dispatchMetadataAction($md, $mode, $dry_run=false)
|
public function dispatchMetadata($md, $mode, $dry_run=false)
|
||||||
{
|
{
|
||||||
// Replace this compound result in a hash with proper error handling later on
|
// Replace this compound result in a hash with proper error handling later on
|
||||||
$return_hash = array();
|
$return_hash = array();
|
||||||
if ( $dry_run ) { // for debugging we return garbage not to screw around with the db
|
if ( $dry_run ) { // for debugging we return garbage not to screw around with the db
|
||||||
|
@ -587,7 +587,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
// Removing 'mode' key from $info_json might not be necessary...
|
// Removing 'mode' key from $info_json might not be necessary...
|
||||||
$mode = $info_json['mode'];
|
$mode = $info_json['mode'];
|
||||||
unset( $info_json['mode'] );
|
unset( $info_json['mode'] );
|
||||||
$response = $this->dispatchMetadataAction($info_json, $mode, $dry_run=$dry);
|
$response = $this->dispatchMetadata($info_json, $mode, $dry_run=$dry);
|
||||||
// We tack on the 'key' back to every request in case the would like to associate
|
// We tack on the 'key' back to every request in case the would like to associate
|
||||||
// his requests with particular responses
|
// his requests with particular responses
|
||||||
$response['key'] = $k;
|
$response['key'] = $k;
|
||||||
|
|
|
@ -451,8 +451,13 @@ class Application_Model_StoredFile
|
||||||
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
|
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Insert($md=null)
|
public static function Insert($md)
|
||||||
{
|
{
|
||||||
|
// save some work by checking if filepath is given right away
|
||||||
|
if( !isset($md['MDATA_KEY_FILEPATH']) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$file = new CcFiles();
|
$file = new CcFiles();
|
||||||
$file->setDbUtime(new DateTime("now", new DateTimeZone("UTC")));
|
$file->setDbUtime(new DateTime("now", new DateTimeZone("UTC")));
|
||||||
$file->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
|
$file->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
|
||||||
|
@ -460,22 +465,14 @@ class Application_Model_StoredFile
|
||||||
$storedFile = new Application_Model_StoredFile();
|
$storedFile = new Application_Model_StoredFile();
|
||||||
$storedFile->_file = $file;
|
$storedFile->_file = $file;
|
||||||
|
|
||||||
if (isset($md['MDATA_KEY_FILEPATH'])) {
|
// removed "//" in the path. Always use '/' for path separator
|
||||||
// removed "//" in the path. Always use '/' for path separator
|
$filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']);
|
||||||
$filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']);
|
$res = $storedFile->setFilePath($filepath);
|
||||||
$res = $storedFile->setFilePath($filepath);
|
if ($res === -1) {
|
||||||
if ($res === -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
$storedFile->setMetadata($md);
|
||||||
if (isset($md)) {
|
return $storedFile;
|
||||||
$storedFile->setMetadata($md);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $storedFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,6 @@ import math
|
||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import media.update.replaygain as gain
|
|
||||||
from media.monitor.exceptions import BadSongFile
|
from media.monitor.exceptions import BadSongFile
|
||||||
from media.monitor.log import Loggable
|
from media.monitor.log import Loggable
|
||||||
import media.monitor.pure as mmp
|
import media.monitor.pure as mmp
|
||||||
|
@ -161,8 +160,6 @@ class Metadata(Loggable):
|
||||||
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
|
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
|
||||||
# Now we must load the md5:
|
# Now we must load the md5:
|
||||||
self.__metadata['MDATA_KEY_MD5'] = mmp.file_md5(fpath,max_length=100)
|
self.__metadata['MDATA_KEY_MD5'] = mmp.file_md5(fpath,max_length=100)
|
||||||
self.__metadata['MDATA_KEY_REPLAYGAIN'] = \
|
|
||||||
gain.calculate_replay_gain(fpath)
|
|
||||||
|
|
||||||
def is_recorded(self):
|
def is_recorded(self):
|
||||||
return mmp.is_airtime_recorded( self.__metadata )
|
return mmp.is_airtime_recorded( self.__metadata )
|
||||||
|
|
Loading…
Reference in New Issue