diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 7ff0bb56b..08563f98e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -438,9 +438,11 @@ class StoredFile { * Get the URL to access this file. */ public function getFileUrl() - { - global $CC_CONFIG; - return "http://$CC_CONFIG[baseUrl]:$CC_CONFIG[basePort]/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); + { + $serverName = $_SERVER['SERVER_NAME']; + $serverPort = $_SERVER['SERVER_PORT']; + + return "http://$serverName:$serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); } /** diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index fe50d4a53..bc0e66ae1 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -62,7 +62,7 @@ python ${SCRIPTPATH}/../python_apps/create-pypo-user.py set +e php ${SCRIPTPATH}/include/airtime-install.php $@ -$result=$? +result=$? if [ "$result" -eq "2" ]; then #We've just finished an upgrade, so let's exit exit 0 diff --git a/install_minimal/upgrades/airtime-1.9.4/airtime-upgrade.php b/install_minimal/upgrades/airtime-1.9.4/airtime-upgrade.php index 888b0a7f9..41d35436e 100644 --- a/install_minimal/upgrades/airtime-1.9.4/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-1.9.4/airtime-upgrade.php @@ -3,13 +3,27 @@ class Airtime194Upgrade{ const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg"; + const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf"; const CONF_PYPO_GRP = "pypo"; public static function upgradeLiquidsoapCfgPerms(){ chmod(self::CONF_FILE_LIQUIDSOAP, 0640); chgrp(self::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP); } + + public static function InstallAirtimePhpServerCode($phpDir) + { + $AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc'); + + echo "* Installing PHP code to ".$phpDir.PHP_EOL; + exec("mkdir -p ".$phpDir); + exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir); + } } + +$values = parse_ini_file(AirtimeIni194::CONF_FILE_AIRTIME, true); +$phpDir = $values['general']['airtime_dir']; +Airtime194Upgrade::InstallAirtimePhpServerCode($phpDir); Airtime194Upgrade::upgradeLiquidsoapCfgPerms(); diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 6c531cabd..544312773 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -178,7 +178,7 @@ class PypoFetch(Thread): scheduled_data = dict() scheduled_data['liquidsoap_playlists'] = liquidsoap_playlists scheduled_data['schedule'] = playlists - scheduled_data['stream_metadata'] = schedule_data["stream_metadata"] + scheduled_data['stream_metadata'] = schedule_data["stream_metadata"] self.queue.put(scheduled_data) # cleanup diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index a4cc46282..21d2a42b9 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -41,13 +41,7 @@ class PypoPush(Thread): self.playlists = dict() self.stream_metadata = dict() - """ - push_ahead2 MUST be < push_ahead. The difference in these two values - gives the number of seconds of the window of opportunity for the scheduler - to catch when a playlist is to be played. - """ self.push_ahead = 10 - self.push_ahead2 = self.push_ahead -5 #toggle between "stop" and "play". Keeps track of the state of #liquidsoap @@ -82,26 +76,17 @@ class PypoPush(Thread): currently_on_air = False if schedule: - playedItems = self.load_schedule_tracker() - timenow = time.time() tcoming = time.localtime(timenow + self.push_ahead) str_tcoming_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming[0], tcoming[1], tcoming[2], tcoming[3], tcoming[4], tcoming[5]) - tcoming2 = time.localtime(timenow + self.push_ahead2) - str_tcoming2_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming2[0], tcoming2[1], tcoming2[2], tcoming2[3], tcoming2[4], tcoming2[5]) - tnow = time.localtime(timenow) str_tnow_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tnow[0], tnow[1], tnow[2], tnow[3], tnow[4], tnow[5]) for pkey in schedule: plstart = schedule[pkey]['start'][0:19] - #plstart = pkey[0:19] - #playedFlag = (pkey in playedItems) and playedItems[pkey].get("played", 0) - playedFlag = False - - if plstart == str_tcoming_s or (plstart < str_tcoming_s and plstart > str_tcoming2_s and not playedFlag): + if str_tnow_s <= plstart and plstart < str_tcoming_s: logger.debug('Preparing to push playlist scheduled at: %s', pkey) playlist = schedule[pkey] @@ -111,14 +96,6 @@ class PypoPush(Thread): # force liquidsoap to refresh. if (self.push_liquidsoap(pkey, schedule, playlists) == 1): logger.debug("Pushed to liquidsoap, updating 'played' status.") - # Marked the current playlist as 'played' in the schedule tracker - # so it is not called again in the next push loop. - # Write changes back to tracker file. - playedItems[pkey] = playlist - playedItems[pkey]['played'] = 1 - schedule_tracker = open(self.schedule_tracker_file, "w") - pickle.dump(playedItems, schedule_tracker) - schedule_tracker.close() # Call API to update schedule states logger.debug("Doing callback to server to update 'played' status.") @@ -129,8 +106,6 @@ class PypoPush(Thread): if show_start <= str_tnow_s and str_tnow_s < show_end: currently_on_air = True - else: - pass if not currently_on_air and self.liquidsoap_state_play: logger.debug('Notifying Liquidsoap to stop playback.') @@ -202,29 +177,6 @@ class PypoPush(Thread): status = 0 return status - def load_schedule_tracker(self): - logger = logging.getLogger('push') - playedItems = dict() - - # create the file if it doesnt exist - if (not os.path.exists(self.schedule_tracker_file)): - try: - logger.debug('creating file ' + self.schedule_tracker_file) - schedule_tracker = open(self.schedule_tracker_file, 'w') - pickle.dump(playedItems, schedule_tracker) - schedule_tracker.close() - except Exception, e: - logger.error('Error creating schedule tracker file: %s', e) - else: - try: - schedule_tracker = open(self.schedule_tracker_file, "r") - playedItems = pickle.load(schedule_tracker) - schedule_tracker.close() - except Exception, e: - logger.error('Unable to load schedule tracker file: %s', e) - - return playedItems - def run(self): loops = 0 heartbeat_period = math.floor(30/PUSH_INTERVAL)