From 81887b291a837eecd804fb993b066df0bf69795d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:39:28 -0400 Subject: [PATCH 01/16] cc-4129: Changed unused organization to label --- python_apps/media-monitor2/media/monitor/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index 0fc278e9e..8a56d51e1 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -32,7 +32,7 @@ airtime2mutagen = { "MDATA_KEY_MOOD" : "mood", "MDATA_KEY_TRACKNUMBER" : "tracknumber", "MDATA_KEY_BPM" : "bpm", - "MDATA_KEY_LABEL" : "organization", + "MDATA_KEY_LABEL" : "label", "MDATA_KEY_COMPOSER" : "composer", "MDATA_KEY_ENCODER" : "encodedby", "MDATA_KEY_CONDUCTOR" : "conductor", From 018b50d316125903c03b8551265df517de87eb8d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:45:10 -0400 Subject: [PATCH 02/16] added better logging --- airtime_mvc/application/controllers/AudiopreviewController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index c66539c37..d81e00030 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -55,7 +55,7 @@ class AudiopreviewController extends Zend_Controller_Action $uri = $webstream->getDbUrl(); $mime = $webstream->getDbMime(); } else { - throw new Exception("Unknown type for audio preview!"); + throw new Exception("Unknown type for audio preview!.Type=$type"); } $this->view->uri = $uri; From 6fc0d50c9fd5cb50162975821e6bcc61615f1bff Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:46:35 -0400 Subject: [PATCH 03/16] lined up --- .../controllers/AudiopreviewController.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index d81e00030..bd7505595 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -21,9 +21,9 @@ class AudiopreviewController extends Zend_Controller_Action { global $CC_CONFIG; - $audioFileID = $this->_getParam('audioFileID'); + $audioFileID = $this->_getParam('audioFileID'); $audioFileArtist = $this->_getParam('audioFileArtist'); - $audioFileTitle = $this->_getParam('audioFileTitle'); + $audioFileTitle = $this->_getParam('audioFileTitle'); $type = $this->_getParam('type'); $request = $this->getRequest(); @@ -47,23 +47,23 @@ class AudiopreviewController extends Zend_Controller_Action } if ($type == "audioclip") { - $uri = "/api/get-media/file/".$audioFileID; + $uri = "/api/get-media/file/".$audioFileID; $media = Application_Model_StoredFile::Recall($audioFileID); - $mime = $media->getPropelOrm()->getDbMime(); + $mime = $media->getPropelOrm()->getDbMime(); } elseif ($type == "stream") { $webstream = CcWebstreamQuery::create()->findPk($audioFileID); - $uri = $webstream->getDbUrl(); - $mime = $webstream->getDbMime(); + $uri = $webstream->getDbUrl(); + $mime = $webstream->getDbMime(); } else { throw new Exception("Unknown type for audio preview!.Type=$type"); } - $this->view->uri = $uri; - $this->view->mime = $mime; - $this->view->audioFileID = $audioFileID; + $this->view->uri = $uri; + $this->view->mime = $mime; + $this->view->audioFileID = $audioFileID; $this->view->audioFileArtist = $audioFileArtist; - $this->view->audioFileTitle = $audioFileTitle; - $this->view->type = $type; + $this->view->audioFileTitle = $audioFileTitle; + $this->view->type = $type; $this->_helper->viewRenderer->setRender('audio-preview'); } From 8657a804595b826d0664f60cc2647369319cad3e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:51:13 -0400 Subject: [PATCH 04/16] removed return '' --- airtime_mvc/application/models/StoredFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 420510953..6c8c5d992 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -407,7 +407,7 @@ SQL; */ public function getFileExtension() { - return ""; + //return ""; // TODO : what's the point of having this function? Can we not just use // the extension from the file_path column from cc_files? $mime = $this->_file->getDbMime(); From bc873a3ece825fc36c45ed5bccd1e993d7af4bb6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:04:54 -0400 Subject: [PATCH 05/16] Added extension handling for file path --- airtime_mvc/application/models/StoredFile.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 6c8c5d992..e31e6fd4e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -399,6 +399,17 @@ SQL; $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. * @@ -407,9 +418,13 @@ SQL; */ public function getFileExtension() { - //return ""; // TODO : what's the point of having this function? Can we not just use // the extension from the file_path column from cc_files? + $possible_ext = $this->getRealFileExtension(); + if ($possible_ext !== "") { + return $possible_ext; + } + $mime = $this->_file->getDbMime(); if ($mime == "audio/ogg" || $mime == "application/ogg") { From f9319b869afd8711222108d3973cb8c0856c4df9 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:08:30 -0400 Subject: [PATCH 06/16] Corrected comments --- airtime_mvc/application/models/StoredFile.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index e31e6fd4e..dd945d328 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -418,13 +418,15 @@ SQL; */ public function getFileExtension() { - // TODO : what's the point of having this function? Can we not just use - // the extension from the file_path column from cc_files? $possible_ext = $this->getRealFileExtension(); if ($possible_ext !== "") { 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(); if ($mime == "audio/ogg" || $mime == "application/ogg") { From d2f43058c28ed84b35981a6b5796336d6866f097 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:09:28 -0400 Subject: [PATCH 07/16] fixed comment --- airtime_mvc/application/models/StoredFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index dd945d328..b0a0f4056 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -582,7 +582,7 @@ SQL; /** * 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 */ public static function RecallByFilepath($p_filepath) From a22ba39de10536852da894c3f62678d04fc64bfe Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:26:07 -0400 Subject: [PATCH 08/16] formatting --- airtime_mvc/application/models/StoredFile.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index b0a0f4056..1135084db 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -678,21 +678,21 @@ SQL; $fileSelect[] = $key; $streamSelect[] = "NULL::NUMERIC AS ".$key; } elseif ($key === "lptime") { - $plSelect[] = "NULL::TIMESTAMP AS ".$key; - $blSelect[] = "NULL::TIMESTAMP AS ".$key; - $fileSelect[] = $key; + $plSelect[] = "NULL::TIMESTAMP AS ".$key; + $blSelect[] = "NULL::TIMESTAMP AS ".$key; + $fileSelect[] = $key; $streamSelect[] = $key; } //same columns in each table. else if (in_array($key, array("length", "utime", "mtime"))) { - $plSelect[] = $key; - $blSelect[] = $key; - $fileSelect[] = $key; + $plSelect[] = $key; + $blSelect[] = $key; + $fileSelect[] = $key; $streamSelect[] = $key; } elseif ($key === "year") { - $plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; - $blSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; - $fileSelect[] = "year AS ".$key; + $plSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; + $blSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; + $fileSelect[] = "year AS ".$key; $streamSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key; } //need to cast certain data as ints for the union to search on. From b0f2176329c15955eb46609cece231f557290bf2 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 18 Sep 2012 12:40:44 -0400 Subject: [PATCH 09/16] fix some TODO's in webstream.php --- .../application/controllers/WebstreamController.php | 11 ----------- airtime_mvc/application/models/Webstream.php | 11 +++++------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index e9e93fe44..ebb5acbf6 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -35,17 +35,6 @@ class WebstreamController extends Zend_Controller_Action $webstream->setDbUtime(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 Application_Model_Library::changePlaylist(null, null); diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index e3f08858a..561f97b12 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -39,7 +39,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable public function getLastModified($p_type) { - return "modified"; + return $this->webstream->getDbMtime(); } public function getDefaultLength() @@ -215,15 +215,16 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable return true; } - // TODO : properly implement this interface + // TODO : Fix this interface 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) { - throw new Exception("setName is not imeplemented by WebStream yet"); + $this->webstream->setDbName($name); } public function setLastPlayed($timestamp) @@ -243,8 +244,6 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable //TODO: What if invalid url? $content = curl_exec($ch); - Logging::debug($content); - // close cURL resource, and free up system resources curl_close($ch); From b1f0bdb6ae49d9b2a56294b4ce295984685a7d2c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 18 Sep 2012 12:41:19 -0400 Subject: [PATCH 10/16] CC-4377: Make sure upgrade script handles new required packages -removing package checking from main install script (not its duty to perform this) --- install_minimal/airtime-install | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 14f713296..b0034ab59 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -82,36 +82,6 @@ SCRIPT=`readlink -f $0` SCRIPTPATH=`dirname $SCRIPT` 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" set +e update-locale From 6ac241b1fc787a72ad4c9a87682187ae7775b146 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:48:45 -0400 Subject: [PATCH 11/16] Added todo --- airtime_mvc/application/models/StoredFile.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 1135084db..ac858e521 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -729,6 +729,7 @@ SQL; $unionTable = "({$plTable} UNION {$blTable} UNION {$fileTable} UNION {$streamTable}) AS RESULTS"; //choose which table we need to select data from. + // TODO : use constants instead of numbers -- RG switch ($type) { case 0: $fromTable = $unionTable; From b069b1254e000b2a3607cd153c7eb85afb315e0d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 12:56:01 -0400 Subject: [PATCH 12/16] Aligned --- airtime_mvc/application/models/StoredFile.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index ac858e521..d905b8e80 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1182,11 +1182,11 @@ SQL; if (Application_Model_Preference::GetUploadToSoundcloudOption()) { for ($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { $description = $file->getDbTrackTitle(); - $tag = array(); - $genre = $file->getDbGenre(); - $release = $file->getDbYear(); + $tag = array(); + $genre = $file->getDbGenre(); + $release = $file->getDbYear(); try { - $soundcloud = new Application_Model_Soundcloud(); + $soundcloud = new Application_Model_Soundcloud(); $soundcloud_res = $soundcloud->uploadTrack( $this->getFilePath(), $this->getName(), $description, $tag, $release, $genre); @@ -1196,9 +1196,9 @@ SQL; break; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { $code = $e->getHttpCode(); - $msg = $e->getHttpBody(); + $msg = $e->getHttpBody(); $temp = explode('"error":',$msg); - $msg = trim($temp[1], '"}'); + $msg = trim($temp[1], '"}'); $this->setSoundCloudErrorCode($code); $this->setSoundCloudErrorMsg($msg); // setting sc id to -3 which indicates error From 98f0692b8d569ec462fd63a9c9c523e618a29d25 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 18 Sep 2012 14:40:18 -0400 Subject: [PATCH 13/16] CC-4457: Media Library: The background of 'Adding items' is minimize to a point - fixed --- .../public/js/airtime/library/events/library_playlistbuilder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js index 751024e24..8c3239927 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js @@ -64,7 +64,7 @@ var AIRTIME = (function(AIRTIME) { helper : function() { 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(); // dragging an element that has an unselected From 3a60d729fdc7ad4709212961292f61da01006311 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 15:02:07 -0400 Subject: [PATCH 14/16] added todo --- airtime_mvc/application/models/StoredFile.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index d905b8e80..22b7a431e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1197,6 +1197,7 @@ SQL; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { $code = $e->getHttpCode(); $msg = $e->getHttpBody(); + // TODO : Do not parse JSON by hand $temp = explode('"error":',$msg); $msg = trim($temp[1], '"}'); $this->setSoundCloudErrorCode($code); From 2cfb0c85d5c0b43cb5a1466113c4a4aaf12b577b Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 15:04:22 -0400 Subject: [PATCH 15/16] Formatted sql --- airtime_mvc/application/models/StoredFile.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 22b7a431e..deada4d38 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1057,12 +1057,14 @@ SQL; { $con = Propel::getConnection(); - $sql = "SELECT id, filepath as fp" - ." FROM CC_FILES" - ." WHERE directory = :dir_id" - ." AND file_exists = 'TRUE'" - ." AND replay_gain is NULL" - ." LIMIT :lim"; + $sql = <<prepare($sql); $stmt->bindParam(':dir_id', $dir_id); @@ -1171,6 +1173,8 @@ SQL; return $this->_file->getDbFileExists(); } + + // note: never call this method from controllers because it does a sleep public function uploadToSoundCloud() { global $CC_CONFIG; From 66aee1a01b91ea1727b5a3d7d45b5234a43081b2 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 15:13:39 -0400 Subject: [PATCH 16/16] Added TODO --- python_apps/media-monitor2/media/monitor/organizer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python_apps/media-monitor2/media/monitor/organizer.py b/python_apps/media-monitor2/media/monitor/organizer.py index 7bead4e21..713bd2156 100644 --- a/python_apps/media-monitor2/media/monitor/organizer.py +++ b/python_apps/media-monitor2/media/monitor/organizer.py @@ -66,6 +66,7 @@ class Organizer(ReportHandler,Loggable): # See hack in mmp.magic_move def new_dir_watch(d): + # TODO : rewrite as return lambda : dispatcher.send(... def cb(): dispatcher.send(signal="add_subwatch", sender=self, directory=d)