Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
denise 2012-09-18 15:14:57 -04:00
commit 0386f8a9cb
8 changed files with 68 additions and 86 deletions

View File

@ -21,9 +21,9 @@ class AudiopreviewController extends Zend_Controller_Action
{ {
global $CC_CONFIG; global $CC_CONFIG;
$audioFileID = $this->_getParam('audioFileID'); $audioFileID = $this->_getParam('audioFileID');
$audioFileArtist = $this->_getParam('audioFileArtist'); $audioFileArtist = $this->_getParam('audioFileArtist');
$audioFileTitle = $this->_getParam('audioFileTitle'); $audioFileTitle = $this->_getParam('audioFileTitle');
$type = $this->_getParam('type'); $type = $this->_getParam('type');
$request = $this->getRequest(); $request = $this->getRequest();
@ -47,23 +47,23 @@ class AudiopreviewController extends Zend_Controller_Action
} }
if ($type == "audioclip") { if ($type == "audioclip") {
$uri = "/api/get-media/file/".$audioFileID; $uri = "/api/get-media/file/".$audioFileID;
$media = Application_Model_StoredFile::Recall($audioFileID); $media = Application_Model_StoredFile::Recall($audioFileID);
$mime = $media->getPropelOrm()->getDbMime(); $mime = $media->getPropelOrm()->getDbMime();
} elseif ($type == "stream") { } elseif ($type == "stream") {
$webstream = CcWebstreamQuery::create()->findPk($audioFileID); $webstream = CcWebstreamQuery::create()->findPk($audioFileID);
$uri = $webstream->getDbUrl(); $uri = $webstream->getDbUrl();
$mime = $webstream->getDbMime(); $mime = $webstream->getDbMime();
} else { } else {
throw new Exception("Unknown type for audio preview!"); throw new Exception("Unknown type for audio preview!.Type=$type");
} }
$this->view->uri = $uri; $this->view->uri = $uri;
$this->view->mime = $mime; $this->view->mime = $mime;
$this->view->audioFileID = $audioFileID; $this->view->audioFileID = $audioFileID;
$this->view->audioFileArtist = $audioFileArtist; $this->view->audioFileArtist = $audioFileArtist;
$this->view->audioFileTitle = $audioFileTitle; $this->view->audioFileTitle = $audioFileTitle;
$this->view->type = $type; $this->view->type = $type;
$this->_helper->viewRenderer->setRender('audio-preview'); $this->_helper->viewRenderer->setRender('audio-preview');
} }

View File

@ -35,17 +35,6 @@ class WebstreamController extends Zend_Controller_Action
$webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbUtime(new DateTime("now", new DateTimeZone('UTC')));
$webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC'))); $webstream->setDbMtime(new DateTime("now", new DateTimeZone('UTC')));
/*
$type = "stream";
$objInfo = Application_Model_Library::getObjInfo($type);
$obj = new $objInfo['className']($webstream);
$obj->setName($webstream->getDbName());
$obj->setMetadata('dc:creator', $userInfo->id);
$type = "stream";
Application_Model_Library::changePlaylist($obj->getId(), $type);
*/
//clear the session in case an old playlist was open: CC-4196 //clear the session in case an old playlist was open: CC-4196
Application_Model_Library::changePlaylist(null, null); Application_Model_Library::changePlaylist(null, null);

View File

@ -399,6 +399,17 @@ SQL;
$this->_file->save(); $this->_file->save();
} }
public function getRealFileExtension() {
$path = $this->_file->getDbFilepath();
$path_elements = explode('.', $path);
if (count($path_elements) < 2) {
return "";
} else {
return $path_elements[count($path_elements) - 1];
}
}
/** /**
* Return suitable extension. * Return suitable extension.
* *
@ -407,9 +418,15 @@ SQL;
*/ */
public function getFileExtension() public function getFileExtension()
{ {
return ""; $possible_ext = $this->getRealFileExtension();
// TODO : what's the point of having this function? Can we not just use if ($possible_ext !== "") {
// the extension from the file_path column from cc_files? return $possible_ext;
}
// We fallback to guessing the extension from the mimetype if we
// cannot extract it from the file name
$mime = $this->_file->getDbMime(); $mime = $this->_file->getDbMime();
if ($mime == "audio/ogg" || $mime == "application/ogg") { if ($mime == "audio/ogg" || $mime == "application/ogg") {
@ -565,7 +582,7 @@ SQL;
/** /**
* Fetch the Application_Model_StoredFile by looking up its filepath. * Fetch the Application_Model_StoredFile by looking up its filepath.
* *
* @param string $p_filepath path of file stored in Airtime. * @param string $p_filepath path of file stored in Airtime.
* @return Application_Model_StoredFile|NULL * @return Application_Model_StoredFile|NULL
*/ */
public static function RecallByFilepath($p_filepath) public static function RecallByFilepath($p_filepath)
@ -661,21 +678,21 @@ SQL;
$fileSelect[] = $key; $fileSelect[] = $key;
$streamSelect[] = "NULL::NUMERIC AS ".$key; $streamSelect[] = "NULL::NUMERIC AS ".$key;
} elseif ($key === "lptime") { } elseif ($key === "lptime") {
$plSelect[] = "NULL::TIMESTAMP AS ".$key; $plSelect[] = "NULL::TIMESTAMP AS ".$key;
$blSelect[] = "NULL::TIMESTAMP AS ".$key; $blSelect[] = "NULL::TIMESTAMP AS ".$key;
$fileSelect[] = $key; $fileSelect[] = $key;
$streamSelect[] = $key; $streamSelect[] = $key;
} }
//same columns in each table. //same columns in each table.
else if (in_array($key, array("length", "utime", "mtime"))) { else if (in_array($key, array("length", "utime", "mtime"))) {
$plSelect[] = $key; $plSelect[] = $key;
$blSelect[] = $key; $blSelect[] = $key;
$fileSelect[] = $key; $fileSelect[] = $key;
$streamSelect[] = $key; $streamSelect[] = $key;
} elseif ($key === "year") { } elseif ($key === "year") {
$plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; $plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
$blSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; $blSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
$fileSelect[] = "year AS ".$key; $fileSelect[] = "year AS ".$key;
$streamSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; $streamSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
} }
//need to cast certain data as ints for the union to search on. //need to cast certain data as ints for the union to search on.
@ -712,6 +729,7 @@ SQL;
$unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS"; $unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS";
//choose which table we need to select data from. //choose which table we need to select data from.
// TODO : use constants instead of numbers -- RG
switch ($type) { switch ($type) {
case 0: case 0:
$fromTable = $unionTable; $fromTable = $unionTable;
@ -1039,12 +1057,14 @@ SQL;
{ {
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT id, filepath as fp" $sql = <<<SQL
." FROM CC_FILES" SELECT id,
." WHERE directory = :dir_id" filepath AS fp
." AND file_exists = 'TRUE'" FROM cc_files
." AND replay_gain is NULL" WHERE directory = :dir_id
." LIMIT :lim"; AND file_exists = 'TRUE'
AND replay_gain IS NULL LIMIT :lim
SQL;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindParam(':dir_id', $dir_id); $stmt->bindParam(':dir_id', $dir_id);
@ -1153,6 +1173,8 @@ SQL;
return $this->_file->getDbFileExists(); return $this->_file->getDbFileExists();
} }
// note: never call this method from controllers because it does a sleep
public function uploadToSoundCloud() public function uploadToSoundCloud()
{ {
global $CC_CONFIG; global $CC_CONFIG;
@ -1164,11 +1186,11 @@ SQL;
if (Application_Model_Preference::GetUploadToSoundcloudOption()) { if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
for ($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { for ($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
$description = $file->getDbTrackTitle(); $description = $file->getDbTrackTitle();
$tag = array(); $tag = array();
$genre = $file->getDbGenre(); $genre = $file->getDbGenre();
$release = $file->getDbYear(); $release = $file->getDbYear();
try { try {
$soundcloud = new Application_Model_Soundcloud(); $soundcloud = new Application_Model_Soundcloud();
$soundcloud_res = $soundcloud->uploadTrack( $soundcloud_res = $soundcloud->uploadTrack(
$this->getFilePath(), $this->getName(), $description, $this->getFilePath(), $this->getName(), $description,
$tag, $release, $genre); $tag, $release, $genre);
@ -1178,9 +1200,10 @@ SQL;
break; break;
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
$code = $e->getHttpCode(); $code = $e->getHttpCode();
$msg = $e->getHttpBody(); $msg = $e->getHttpBody();
// TODO : Do not parse JSON by hand
$temp = explode('"error":',$msg); $temp = explode('"error":',$msg);
$msg = trim($temp[1], '"}'); $msg = trim($temp[1], '"}');
$this->setSoundCloudErrorCode($code); $this->setSoundCloudErrorCode($code);
$this->setSoundCloudErrorMsg($msg); $this->setSoundCloudErrorMsg($msg);
// setting sc id to -3 which indicates error // setting sc id to -3 which indicates error

View File

@ -39,7 +39,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
public function getLastModified($p_type) public function getLastModified($p_type)
{ {
return "modified"; return $this->webstream->getDbMtime();
} }
public function getDefaultLength() public function getDefaultLength()
@ -215,15 +215,16 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
return true; return true;
} }
// TODO : properly implement this interface // TODO : Fix this interface
public function setMetadata($key, $val) public function setMetadata($key, $val)
{ {
throw new Exception("setMetadata is not imeplemented by WebStream yet"); //This function should not be defined in the interface.
throw new Exception("Not implemented.");
} }
public function setName($name) public function setName($name)
{ {
throw new Exception("setName is not imeplemented by WebStream yet"); $this->webstream->setDbName($name);
} }
public function setLastPlayed($timestamp) public function setLastPlayed($timestamp)
@ -243,8 +244,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
//TODO: What if invalid url? //TODO: What if invalid url?
$content = curl_exec($ch); $content = curl_exec($ch);
Logging::debug($content);
// close cURL resource, and free up system resources // close cURL resource, and free up system resources
curl_close($ch); curl_close($ch);

View File

@ -64,7 +64,7 @@ var AIRTIME = (function(AIRTIME) {
helper : function() { helper : function() {
var $el = $(this), selected = mod var $el = $(this), selected = mod
.getChosenAudioFilesLength(), container, message, li = $("#side_playlist ul li:first"), width = li .getChosenAudioFilesLength(), container, message, li = $("#side_playlist ul[id='spl_sortable'] li:first"), width = li
.width(), height = li.height(); .width(), height = li.height();
// dragging an element that has an unselected // dragging an element that has an unselected

View File

@ -82,36 +82,6 @@ SCRIPT=`readlink -f $0`
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../ AIRTIMEROOT=$SCRIPTPATH/../
#Check if required zend mvc library is present. This is a temporary workaround for 2.0.1,
#and we should probably create a separate file that checks whether ALL dependencies are satisfied before
#allowing the install to continue. However in that case, we wouldn't check for Debian packages so that we
#can become less Debian platform dependent in the future...
set +e
dpkg -l | grep zendframework > /dev/null 2>&1
ZENDFRAMEWORK=$?
dpkg -l | grep libzend-framework-php > /dev/null 2>&1
LIBZEND=$?
dpkg -l | grep lsof > /dev/null 2>&1
LSOF_EXIST=$?
dpkg -l | grep sudo > /dev/null 2>&1
SUDO_EXIST=$?
set -e
if [ "$ZENDFRAMEWORK" != "0" -a "$LIBZEND" != "0" ]; then
echo "zendframework/libzend-framework-php package missing. Please run airtime-full-install"
exit 1
fi
if [ "$LSOF_EXIST" != "0" -o "$SUDO_EXIST" != "0" ]; then
echo "Packages missing. Please run airtime-full-install"
exit 1
fi
echo "* Making sure /etc/default/locale is set properly" echo "* Making sure /etc/default/locale is set properly"
set +e set +e
update-locale update-locale

View File

@ -32,7 +32,7 @@ airtime2mutagen = {
"MDATA_KEY_MOOD" : "mood", "MDATA_KEY_MOOD" : "mood",
"MDATA_KEY_TRACKNUMBER" : "tracknumber", "MDATA_KEY_TRACKNUMBER" : "tracknumber",
"MDATA_KEY_BPM" : "bpm", "MDATA_KEY_BPM" : "bpm",
"MDATA_KEY_LABEL" : "organization", "MDATA_KEY_LABEL" : "label",
"MDATA_KEY_COMPOSER" : "composer", "MDATA_KEY_COMPOSER" : "composer",
"MDATA_KEY_ENCODER" : "encodedby", "MDATA_KEY_ENCODER" : "encodedby",
"MDATA_KEY_CONDUCTOR" : "conductor", "MDATA_KEY_CONDUCTOR" : "conductor",

View File

@ -66,6 +66,7 @@ class Organizer(ReportHandler,Loggable):
# See hack in mmp.magic_move # See hack in mmp.magic_move
def new_dir_watch(d): def new_dir_watch(d):
# TODO : rewrite as return lambda : dispatcher.send(...
def cb(): def cb():
dispatcher.send(signal="add_subwatch", sender=self, dispatcher.send(signal="add_subwatch", sender=self,
directory=d) directory=d)