diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 296cfcdaf..07b58c016 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -125,11 +125,18 @@ class ApiController extends Zend_Controller_Action $media = Application_Model_StoredFile::RecallByGunid($file_id); if ( $media != null ) { + $dir = Application_Model_MusicDir::getDirByPK($media->getDirectory()); + $filepath = $media->getFilePath(); if(is_file($filepath)){ $full_path = $media->getPropelOrm()->getDbFilepath(); - $file_base_name = strrchr($full_path, '/'); - $file_base_name = substr($file_base_name, 1); + + if (strcmp($dir->getType(), 'watched') != 0) { + $file_base_name = strrchr($full_path, '/'); + $file_base_name = substr($file_base_name, 1); + } else { + $file_base_name = $full_path; + } // possibly use fileinfo module here in the future. // http://www.php.net/manual/en/book.fileinfo.php $ext = pathinfo($fileID, PATHINFO_EXTENSION); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 3dd72ff4b..5f75bb0e5 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -391,7 +391,7 @@ class Application_Model_StoredFile { return $directory.$filepath; } - + /** * Set real filename of raw media data * @@ -887,8 +887,9 @@ Logging::log("getting media! - 2"); // Check if file is playable $command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' 2>&1", $audio_file); + exec($command, $output, $rv); - if ($rv != 0 || count($output) != 0) { + if ($rv != 0 || $output[0] == 'TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.') { $result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library."); } else { @@ -1011,6 +1012,10 @@ Logging::log("getting media! - 2"); public function getSoundCloudErrorMsg(){ return $this->_file->getDbSoundCloudErrorMsg(); } + + public function getDirectory(){ + return $this->_file->getDbDirectory(); + } public function setFileExistsFlag($flag){ $this->_file->setDbFileExists($flag)