diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 4e43fb038..852078675 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -89,21 +89,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headScript()->appendFile($baseUrl . '/js/airtime/common/livechat.js?'.filemtime($baseDir.'/js/airtime/common/livechat.js'), 'text/javascript'); } if(isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1){ - // since we need to append google analytic code right before we can't use appendFile function - // we will just store raw html into some variable - $view->google_analytics = ""; + $view->headScript()->appendFile($baseUrl.'/js/libs/google-analytics.js?'.filemtime($baseDir.'/js/libs/google-analytics.js'),'text/javascript'); } } diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index d74104cd2..1068c403f 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -168,7 +168,7 @@ class LibraryController extends Zend_Controller_Action return; } - $res = $file->delete(); + $res = $file->delete(true); if (PEAR::isError($res)) { $this->view->message = $res->getMessage(); diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 62b9343b4..2053a947e 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -205,6 +205,7 @@ class PreferenceController extends Zend_Controller_Action $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); + $values['streamFormat'] = $form->getValue('streamFormat'); } if(!$error){ @@ -214,6 +215,8 @@ class PreferenceController extends Zend_Controller_Action for($i=1;$i<=$num_of_stream;$i++){ Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } + // this goes into cc_pref table + Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); // store stream update timestamp Application_Model_Preference::SetStreamUpdateTimestamp(); Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index d99058fa4..c51ea3dfd 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -303,7 +303,7 @@ class Application_Model_StoredFile { * * @return void|PEAR_Error */ - public function delete() + public function delete($deleteFromPlaylist=false) { if ($this->exists()) { if ($this->getFormat() == 'audioclip') { @@ -314,8 +314,9 @@ class Application_Model_StoredFile { } } - // don't delete from the playslist. We might want to put a flag - //Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId()); + if($deleteFromPlaylist){ + Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId()); + } // set file_exists falg to false $this->_file->setDbFileExists(false); diff --git a/airtime_mvc/public/js/libs/google-analytics.js b/airtime_mvc/public/js/libs/google-analytics.js new file mode 100644 index 000000000..5a9352270 --- /dev/null +++ b/airtime_mvc/public/js/libs/google-analytics.js @@ -0,0 +1,9 @@ +var _gaq = _gaq || []; +_gaq.push(['_setAccount', 'UA-28765064-1']); +_gaq.push(['_trackPageview']); + +(function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); +})(); diff --git a/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 b/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 index 2765f9781..9ac92ce44 100644 --- a/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 +++ b/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 @@ -24,6 +24,7 @@ record_bitrate = 256 record_samplerate = 44100 record_channels = 2 record_sample_size = 16 +record_timeout = 3600 #can be either ogg|mp3, mp3 recording requires installation of the package "lame" record_file_type = 'ogg' \ No newline at end of file diff --git a/python_apps/show-recorder/recorder.cfg b/python_apps/show-recorder/recorder.cfg index c010a8645..d817a32b2 100644 --- a/python_apps/show-recorder/recorder.cfg +++ b/python_apps/show-recorder/recorder.cfg @@ -24,6 +24,7 @@ record_bitrate = 256 record_samplerate = 44100 record_channels = 2 record_sample_size = 16 +record_timeout = 3600 #can be either ogg|mp3, mp3 recording requires installation of the package "lame" record_file_type = 'ogg' diff --git a/python_apps/show-recorder/recorder.py b/python_apps/show-recorder/recorder.py index 80bc4ada8..3ec1caf39 100644 --- a/python_apps/show-recorder/recorder.py +++ b/python_apps/show-recorder/recorder.py @@ -179,7 +179,7 @@ class CommandListener(): self.sr = None self.current_schedule = {} self.shows_to_record = {} - self.time_till_next_show = 3600 + self.time_till_next_show = config["record_timeout"] self.logger.info("RecorderFetch: init complete") self.server_timezone = ''; @@ -213,7 +213,7 @@ class CommandListener(): self.parse_shows(temp) self.server_timezone = m['server_timezone'] elif(command == 'cancel_recording'): - if self.sr.is_recording(): + if self.sr is not None and self.sr.is_recording(): self.sr.cancel_recording() def parse_shows(self, shows): @@ -245,7 +245,7 @@ class CommandListener(): self.logger.debug("Next show %s", next_show) self.logger.debug("Now %s", tnow) else: - out = 3600 + out = config["record_timeout"] return out def start_record(self): @@ -272,8 +272,7 @@ class CommandListener(): self.sr.start() #remove show from shows to record. del self.shows_to_record[start_time] - time_till_next_show = self.get_time_till_next_show() - self.time_till_next_show = time_till_next_show + self.time_till_next_show = self.get_time_till_next_show() except Exception,e : import traceback top = traceback.format_exc() @@ -306,19 +305,40 @@ class CommandListener(): self.logger.error(e) loops = 1 + recording = False + while True: self.logger.info("Loop #%s", loops) try: # block until 5 seconds before the next show start - self.connection.drain_events(timeout=self.time_till_next_show) + self.connection.drain_events(timeout=int(self.time_till_next_show)) except socket.timeout, s: self.logger.info(s) + + # start_record set time_till_next_show to config["record_timeout"] so we should check before + # if timeout amount was 1 hr.. + update_schedule = False + if int(self.time_till_next_show) == int(config["record_timeout"]) : + update_schedule = True + # start recording self.start_record() + + # if real timeout happended get show schedule from airtime + if update_schedule : + temp = self.api_client.get_shows_to_record() + if temp is not None: + shows = temp['shows'] + self.server_timezone = temp['server_timezone'] + self.parse_shows(shows) + self.logger.info("Real Timeout: the schedule has updated") + except Exception, e: - self.logger.info(e) + import traceback + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) time.sleep(3) - loops += 1 if __name__ == '__main__':