From 7e3d25eeaa90337f6e648387f6dc171061e179f1 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 29 Sep 2011 17:10:17 -0400 Subject: [PATCH 01/16] CC-2795: Give option to set download flag of recorded shows uploaded to Soundcloud by default - done --- .../controllers/LibraryController.php | 2 +- .../controllers/PreferenceController.php | 2 ++ .../controllers/ScheduleController.php | 2 +- .../forms/SoundcloudPreferences.php | 24 +++++++++++++++-- airtime_mvc/application/models/Preference.php | 16 ++++++++++++ airtime_mvc/application/models/Soundcloud.php | 4 ++- airtime_mvc/application/models/StoredFile.php | 5 ++-- .../scripts/form/preferences_soundcloud.phtml | 26 +++++++++++++++++++ 8 files changed, 73 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 28987eb81..5f43443ce 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -91,7 +91,7 @@ class LibraryController extends Zend_Controller_Action $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); - if (Application_Model_Preference::GetDoSoundCloudUpload()) { + if (Application_Model_Preference::GetUploadToSoundcloudOption()) { $text = "Upload to Soundcloud"; if(!is_null($file->getSoundCloudId())){ $text = "Re-upload to Soundcloud"; diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 11fead872..2795ee987 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -37,6 +37,8 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]); Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]); + Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); + Application_Model_Preference::SetSoundCloudDownloadbleOption($values["preferences_soundcloud"]["SoundCloudDownloadbleOption"]); Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]); Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index d1ed1674d..0757856ea 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -175,7 +175,7 @@ class ScheduleController extends Zend_Controller_Action if ($showEndDateHelper->getTimestamp() <= $epochNow && $show->isRecorded() - && Application_Model_Preference::GetDoSoundCloudUpload()) { + && Application_Model_Preference::GetUploadToSoundcloudOption()) { if(is_null($show->getSoundCloudFileId())){ $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['uploadToSoundCloud']($id)"), diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index 8639c675b..b9c4c782d 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -11,13 +11,33 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm //enable soundcloud uploads $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Upload Recorded Shows To SoundCloud', + 'label' => 'Automatically Upload Recorded Shows', 'required' => false, 'value' => Application_Model_Preference::GetDoSoundCloudUpload(), 'decorators' => array( 'ViewHelper' ) - )); + )); + + //enable soundcloud uploads option + $this->addElement('checkbox', 'UploadToSoundcloudOption', array( + 'label' => 'Enable Soundcloud Upload', + 'required' => false, + 'value' => Application_Model_Preference::GetUploadToSoundcloudOption(), + 'decorators' => array( + 'ViewHelper' + ) + )); + + //enable downloadable for soundcloud + $this->addElement('checkbox', 'SoundCloudDownloadbleOption', array( + 'label' => 'Automatically Mark Files "Downloadable" on SoundCloud', + 'required' => false, + 'value' => Application_Model_Preference::GetSoundCloudDownloadbleOption(), + 'decorators' => array( + 'ViewHelper' + ) + )); //SoundCloud Username $this->addElement('text', 'SoundCloudUser', array( diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 513067b79..f96475111 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -438,5 +438,21 @@ class Application_Model_Preference public static function GetAirtimeVersion(){ return self::GetValue("system_version"); } + + public static function SetUploadToSoundcloudOption($upload) { + self::SetValue("soundcloud_upload_option", $upload); + } + + public static function GetUploadToSoundcloudOption() { + return self::GetValue("soundcloud_upload_option"); + } + + public static function SetSoundCloudDownloadbleOption($upload) { + self::SetValue("soundcloud_downloadable", $upload); + } + + public static function GetSoundCloudDownloadbleOption() { + return self::GetValue("soundcloud_downloadable"); + } } diff --git a/airtime_mvc/application/models/Soundcloud.php b/airtime_mvc/application/models/Soundcloud.php index 29ad98772..671ac5ec2 100644 --- a/airtime_mvc/application/models/Soundcloud.php +++ b/airtime_mvc/application/models/Soundcloud.php @@ -40,13 +40,15 @@ class Application_Model_AtSoundcloud { $tags = Application_Model_Preference::GetSoundCloudTags(); } + $downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1'?true:false; + $track_data = array( 'track[sharing]' => 'private', 'track[title]' => $filename, 'track[asset_data]' => '@' . $filepath, 'track[tag_list]' => $tags, 'track[description]' => $description, - 'track[downloadable]' => true, + 'track[downloadable]' => $downloadable, ); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 4bb172c8b..4a33a1492 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -931,19 +931,18 @@ class Application_Model_StoredFile { public function uploadToSoundCloud() { global $CC_CONFIG; - + $file = $this->_file; if(is_null($file)) { return "File does not exist"; } - if(Application_Model_Preference::GetDoSoundCloudUpload()) + if(Application_Model_Preference::GetUploadToSoundcloudOption()) { for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) { $description = $file->getDbTrackTitle(); $tag = ""; $genre = $file->getDbGenre(); $release = $file->getDbYear(); - try { $soundcloud = new Application_Model_AtSoundcloud(); $soundcloud_id = $soundcloud->uploadTrack($this->getFilePath(), $this->getName(), $description, $tag, $release, $genre); diff --git a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml index 3ee3ad54e..a06e7722b 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml @@ -1,5 +1,18 @@
+
+ + element->getElement('UploadToSoundcloudOption')->hasErrors()) : ?> +
    + element->getElement('UploadToSoundcloudOption')->getMessages() as $error): ?> +
  • + +
+ +
+
+ + element->getElement('SoundCloudDownloadbleOption')->hasErrors()) : ?> +
    + element->getElement('SoundCloudDownloadbleOption')->getMessages() as $error): ?> +
  • + +
+ +
From 5e9aec93a8e3d393cf4914308305b2b7acee1ed5 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 14:10:47 -0400 Subject: [PATCH 02/16] CC-2919: Media Monitor: recorded show doesn't show on library after recording is done - fixed - extra fix: Airtime wasn't updating file when updating metadata --- .../controllers/LibraryController.php | 5 ++++- python_apps/api_clients/api_client.py | 2 +- .../airtimefilemonitor/airtimemetadata.py | 2 +- .../airtimefilemonitor/airtimeprocessevent.py | 18 +++++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 5f43443ce..c69014689 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -213,7 +213,10 @@ class LibraryController extends Zend_Controller_Action $file->setDbColMetadata($formdata); $data = $file->getMetadata(); - + + // set MDATA_KEY_FILEPATH + $data['MDATA_KEY_FILEPATH'] = $file->getFilePath(); + Logging::log($data['MDATA_KEY_FILEPATH']); Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data); $this->_helper->redirector('index'); diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 348cb6b53..62feb1ee0 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -422,7 +422,7 @@ class AirTimeApiClient(ApiClientInterface): elapsed = (time.time() - start) logger.info("time taken to get response %s", elapsed) - if(is_record): + if("error" not in response and is_record): url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_recorded"]) url = url.replace("%%fileid%%", str(response[u'id'])) url = url.replace("%%showinstanceid%%", str(md['MDATA_KEY_TRACKNUMBER'])) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py index 8214aadf8..18edbc7c5 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py @@ -125,7 +125,7 @@ class AirtimeMetadata: self.logger.debug("Saving %s to file", key) self.logger.debug(value) if isinstance(value, basestring) and (len(value) > 0): - airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8") + airtime_file[self.airtime2mutagen[key]] = api_client.encode_to(value, 'utf-8') elif isinstance(value, int): airtime_file[self.airtime2mutagen[key]] = str(value) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 189eed7ec..fd121c725 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -36,6 +36,7 @@ class AirtimeProcessEvent(ProcessEvent): self.md_manager = AirtimeMetadata() self.mmc = mmc self.api_client = api_client + self.create_dict = {} def add_filepath_to_ignore(self, filepath): self.ignore_event.add(filepath) @@ -87,6 +88,14 @@ class AirtimeProcessEvent(ProcessEvent): else: self.logger.info("Removing the watch folder failed: %s", res['msg']['error']) + def process_IN_CREATE(self, event): + self.logger.info("event: %s", event) + if not event.dir: + if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory): + self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True}) + self.create_dict[event.pathname] = time.time() + + #event.dir: True if the event was raised against a directory. #event.name: filename #event.pathname: pathname (str): Concatenation of 'path' and 'name'. @@ -94,7 +103,10 @@ class AirtimeProcessEvent(ProcessEvent): # copy was done. Hence, IN_CLOSE_WRITE is the correct one to handle. def process_IN_CLOSE_WRITE(self, event): self.logger.info("event: %s", event) - self.handle_created_file(event.dir, event.pathname, event.name) + self.logger.info("create_dict: %s", self.create_dict) + if event.pathname in self.create_dict: + self.create_dict.pop(event.pathname) + self.handle_created_file(event.dir, event.pathname, event.name) def handle_created_file(self, dir, pathname, name): if not dir: @@ -255,6 +267,10 @@ class AirtimeProcessEvent(ProcessEvent): del self.cookies_IN_MOVED_FROM[k] self.handle_removed_file(False, event.pathname) + for k, t in self.create_dict.items(): + now = time.time() + if now - t > 5: + del self.create_dict[k] #check for any events received from Airtime. try: From 4f11428b605fa27f552f427f1c8144ca3d575950 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 14:13:02 -0400 Subject: [PATCH 03/16] CC-2920: Playlist: soundcloud icon appears multiple time when click on reupload to soundcloud - fixed --- airtime_mvc/public/js/airtime/library/library.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 6ff2770da..de461b3e0 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -154,8 +154,12 @@ function dtDrawCallback() { } function addProgressIcon(id) { - $("#au_"+id).find("td:eq(0)").append('') - $("span[id="+id+"]").addClass("progress"); + if($("#au_"+id).find("td:eq(0)").find("span").length > 0){ + $("#au_"+id).find("td:eq(0)").find("span").removeClass(); + }else{ + $("#au_"+id).find("td:eq(0)").append('') + } + $("span[id="+id+"]").addClass("small-icon progress"); } function checkSCUploadStatus(){ From 1d172ca630464730920f0d3584887e6ec287e4f8 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 14:26:10 -0400 Subject: [PATCH 04/16] CC-2904: Space missing between two boxes on "Playlist Builder" - fixed --- airtime_mvc/application/layouts/scripts/library.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index e04678c0b..f84bd868c 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -20,7 +20,7 @@
-
layout()->library ?>
+
layout()->library ?>
layout()->spl ?>
From 3ac50b0183d28477890f1d4fe76a5fe550dd4c10 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 15:25:55 -0400 Subject: [PATCH 05/16] CC-2904: Space missing between two boxes on "Playlist Builder" - fixed - extra change: bug on flag name change --- airtime_mvc/application/models/Preference.php | 3 ++ .../scripts/form/stream-setting-form.phtml | 30 +++++++++---------- .../scripts/preference/stream-setting.phtml | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index b565cdfb1..fb361501f 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -432,6 +432,9 @@ class Application_Model_Preference } public static function GetEnableStreamConf(){ + if(self::GetValue("enable_stream_conf") == Null){ + return "true"; + } return self::GetValue("enable_stream_conf"); } diff --git a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml index 5d36c5dfc..8c2777d61 100644 --- a/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml +++ b/airtime_mvc/application/views/scripts/form/stream-setting-form.phtml @@ -64,10 +64,10 @@ Additional Options
-
+
-
+
element->getElement('user')?> element->getElement('user')->hasErrors()) : ?>
    @@ -77,10 +77,10 @@
-
+
-
+
element->getElement('pass')?> element->getElement('pass')->hasErrors()) : ?>
    @@ -93,10 +93,10 @@
    The following info will be displayed to listeners in their media player:
    -
    +
    -
    +
    element->getElement('description')?> element->getElement('description')->hasErrors()) : ?>
      @@ -106,10 +106,10 @@
    -
    +
    -
    +
    element->getElement('url')?> (Your radio station website) element->getElement('url')->hasErrors()) : ?> @@ -120,10 +120,10 @@
-
+
-
+
element->getElement('genre')?> element->getElement('genre')->hasErrors()) : ?>
    @@ -133,10 +133,10 @@
-
+
-
+
element->getElement('mount')?> element->getElement('mount')->hasErrors()) : ?>
    @@ -148,11 +148,11 @@
-
+
-
-

+
+
diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml index aa413857b..b86bbc855 100644 --- a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -1,5 +1,5 @@
-

Stream Settings

+

enable_stream_conf == "true"){?>style="float:left">Stream Settings

enable_stream_conf == "true"){?>
From 441b983665a61702d577b1cb162e6baa1b2ed882 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 15:27:10 -0400 Subject: [PATCH 06/16] CC-2748: Make Airtime look good in IE - fixed --- airtime_mvc/application/views/scripts/plupload/index.phtml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/airtime_mvc/application/views/scripts/plupload/index.phtml b/airtime_mvc/application/views/scripts/plupload/index.phtml index 92c98cc93..cf236b8d6 100644 --- a/airtime_mvc/application/views/scripts/plupload/index.phtml +++ b/airtime_mvc/application/views/scripts/plupload/index.phtml @@ -1,3 +1,8 @@ +
From aebcfb945024e0afc9c5b24062efd66602724f22 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 3 Oct 2011 15:35:31 -0400 Subject: [PATCH 07/16] CC-2905: Add indentation on checkboxes on SoundCloud setting - fixed --- .../views/scripts/form/preferences_soundcloud.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml index a06e7722b..99456616a 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml @@ -13,7 +13,7 @@ -
+
-
+