Merge branch '1.9.1' into devel

Conflicts:
	VERSION
	airtime_mvc/application/configs/constants.php
	install_minimal/include/airtime-upgrade.php
	python_apps/api_clients/api_client.py
	python_apps/pypo/pypofetch.py
This commit is contained in:
james 2011-08-26 12:56:10 -04:00
commit 56ad8c6b3d
17 changed files with 545 additions and 13 deletions

View File

@ -1,3 +1,20 @@
1.9.3 - August 26th, 2011
*Improvements
-It is now possible to upgrade your system while a show is playing.
Playout will be temporarily interrupted for about 5-10 seconds and then
playout will resume. Previously playout would not resume until the next
scheduled show.
*fixes
-Fixed bug where playout system did not work with mono files.
-Fixed bug where sometimes audio files could be played out of order.
1.9.2 - August 23rd, 2011
*Fixes
-Fixed restarting sometimes caused media-monitor to forget all of its watched directories
-Fixed Media-monitor crashes when moving sub-directories within its watched directory
-upgrade script would crash on upgrade from 1.8.2
1.9.1 - August 17th, 2011
*Fixes
-airtime-user shell script failing to start

View File

@ -84,6 +84,9 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetStationCity($values["City"]);
Application_Model_Preference::SetStationDescription($values["Description"]);
Application_Model_Preference::SetStationLogo($imagePath);
if(isset($values["Privacy"])){
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
}
}
$this->view->statusMsg = "<div class='success'>Support setting updated.</div>";
}

View File

@ -326,6 +326,7 @@ class Schedule {
." ON st.instance_id = si.id"
." LEFT JOIN $CC_CONFIG[showTable] as sh"
." ON si.show_id = sh.id"
//The next line ensures we only get songs that haven't ended yet
." WHERE (st.ends >= TIMESTAMP '$p_currentDateTime')"
." AND (st.ends <= TIMESTAMP '$p_toDateTime')"
//next line makes sure that we aren't returning items that
@ -699,6 +700,7 @@ class Schedule {
$playlists[$pkey]['end'] = Schedule::AirtimeTimeToPypoTime($dx["end"]);
}
}
ksort($playlists);
foreach ($playlists as &$playlist)
{
@ -725,6 +727,7 @@ class Schedule {
'end' => Schedule::AirtimeTimeToPypoTime($item["ends"])
);
}
ksort($medias);
$playlist['medias'] = $medias;
}

View File

@ -395,10 +395,10 @@ class StoredFile {
{
$mime = $this->_file->getDbMime();
if ($mime == "audio/vorbis") {
if ($mime == "audio/vorbis" || $mime == "application/ogg") {
return "ogg";
}
else if ($mime == "audio/mp3") {
else if ($mime == "audio/mp3" || $mime == "audio/mpeg") {
return "mp3";
}
}

View File

@ -2,7 +2,7 @@
VIRTUAL_ENV_DIR="/usr/lib/airtime/airtime_virtualenv"
if [ ! -d "$VIRTUAL_ENV_DIR" ]; then
echo -e "\nAirtime 1.9.0 is not installed, cannot uninstall.\n"
echo -e "\nAirtime is not installed, cannot uninstall.\n"
exit 1
fi

View File

@ -69,6 +69,9 @@ if (strcmp($version, "1.9.0") < 0){
if (strcmp($version, "1.9.2") < 0){
system("php ".__DIR__."/../upgrades/airtime-1.9.2/airtime-upgrade.php");
}
if (strcmp($version, "1.9.3") < 0){
system("php ".__DIR__."/../upgrades/airtime-1.9.3/airtime-upgrade.php");
}
if (strcmp($version, "2.0.0") < 0){
system("php ".__DIR__."/../upgrades/airtime-2.0.0/airtime-upgrade.php");
}

View File

@ -66,6 +66,7 @@ class AirtimeInstall{
exec("rm -f /usr/bin/airtime-import");
exec("rm -f /usr/bin/airtime-update-db-settings");
exec("rm -f /usr/bin/airtime-check-system");
exec("rm -f /usr/bin/airtime-user");
}
public static function DbTableExists($p_name)
@ -759,12 +760,13 @@ AirtimeInstall::CreateZendPhpLogFile();
exec("/usr/bin/airtime-pypo-stop");
exec("/usr/bin/airtime-show-recorder-stop");
exec("svc -d /etc/service/pypo");
exec("svc -d /etc/service/pypo/log");
exec("svc -d /etc/service/pypo-liquidsoap");
exec("svc -d /etc/service/pypo-liquidsoap/log");
exec("svc -d /etc/service/recorder");
exec("svc -d /etc/service/recorder/log");
exec("svc -dx /etc/service/pypo");
exec("svc -dx /etc/service/pypo/log");
exec("svc -dx /etc/service/pypo-liquidsoap");
exec("svc -dx /etc/service/pypo-liquidsoap/log");
exec("svc -dx /etc/service/recorder");
exec("svc -dx /etc/service/recorder/log");
exec("killall supervise");
$pathnames = array("/usr/bin/airtime-pypo-start",
"/usr/bin/airtime-pypo-stop",

View File

@ -0,0 +1,23 @@
set daemon 10 # Poll at 10 second intervals
set logfile syslog facility log_daemon
set httpd port 2812 and use address 127.0.0.1
allow localhost
allow admin:monit
check process airtime-playout
with pidfile "/var/run/airtime-playout.pid"
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-playout stop"
check process airtime-liquidsoap
with pidfile "/var/run/airtime-liquidsoap.pid"
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-playout stop"
check process airtime-media-monitor
with pidfile "/var/run/airtime-media-monitor.pid"
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-media-monitor stop"
check process airtime-show-recorder
with pidfile "/var/run/airtime-show-recorder.pid"
start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds
stop program = "/etc/init.d/airtime-show-recorder stop"

View File

@ -0,0 +1,175 @@
<?php
class Airtime193Upgrade{
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);
}
}
class AirtimeIni193{
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
const CONF_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
/**
* This function updates an INI style config file.
*
* A property and the value the property should be changed to are
* supplied. If the property is not found, then no changes are made.
*
* @param string $p_filename
* The path the to the file.
* @param string $p_property
* The property to look for in order to change its value.
* @param string $p_value
* The value the property should be changed to.
*
*/
public static function UpdateIniValue($p_filename, $p_property, $p_value)
{
$lines = file($p_filename);
$n=count($lines);
foreach ($lines as &$line) {
if ($line[0] != "#"){
$key_value = explode("=", $line);
$key = trim($key_value[0]);
if ($key == $p_property){
$line = "$p_property = $p_value".PHP_EOL;
}
}
}
$fp=fopen($p_filename, 'w');
for($i=0; $i<$n; $i++){
fwrite($fp, $lines[$i]);
}
fclose($fp);
}
public static function ReadPythonConfig($p_filename)
{
$values = array();
$lines = file($p_filename);
$n=count($lines);
for ($i=0; $i<$n; $i++) {
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
$info = explode("=", $lines[$i]);
$values[trim($info[0])] = trim($info[1]);
}
}
return $values;
}
public static function MergeConfigFiles($configFiles, $suffix) {
foreach ($configFiles as $conf) {
if (file_exists("$conf$suffix.bak")) {
if($conf === AirtimeIni193::CONF_FILE_AIRTIME) {
// Parse with sections
$newSettings = parse_ini_file($conf, true);
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
}
else {
$newSettings = AirtimeIni193::ReadPythonConfig($conf);
$oldSettings = AirtimeIni193::ReadPythonConfig("$conf$suffix.bak");
}
$settings = array_keys($newSettings);
foreach($settings as $section) {
// skip airtim_dir as we want to use new value
if(isset($oldSettings[$section])) {
if(is_array($oldSettings[$section])) {
$sectionKeys = array_keys($newSettings[$section]);
foreach($sectionKeys as $sectionKey) {
if($sectionKey != "airtime_dir"){
if(isset($oldSettings[$section][$sectionKey])) {
AirtimeIni193::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
}
}
}
}
else {
AirtimeIni193::UpdateIniValue($conf, $section, $oldSettings[$section]);
}
}
}
}
}
}
public static function upgradeConfigFiles(){
$configFiles = array(AirtimeIni193::CONF_FILE_AIRTIME,
AirtimeIni193::CONF_FILE_PYPO,
AirtimeIni193::CONF_FILE_RECORDER,
AirtimeIni193::CONF_FILE_LIQUIDSOAP);
// Backup the config files
$suffix = date("Ymdhis")."-1.9.0";
foreach ($configFiles as $conf) {
if (file_exists($conf)) {
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
copy($conf, $conf.$suffix.".bak");
}
}
$default_suffix = "193";
AirtimeIni193::CreateIniFiles($default_suffix);
AirtimeIni193::MergeConfigFiles($configFiles, $suffix);
}
/**
* This function creates the /etc/airtime configuration folder
* and copies the default config files to it.
*/
public static function CreateIniFiles($suffix)
{
if (!file_exists("/etc/airtime/")){
if (!mkdir("/etc/airtime/", 0755, true)){
echo "Could not create /etc/airtime/ directory. Exiting.";
exit(1);
}
}
if (!copy(__DIR__."/airtime.conf.$suffix", AirtimeIni193::CONF_FILE_AIRTIME)){
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/pypo.cfg.$suffix", AirtimeIni193::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/recorder.cfg.$suffix", AirtimeIni193::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
}
if (!copy(__DIR__."/liquidsoap.cfg.$suffix", AirtimeIni193::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
}
}
}
echo "* Updating configFiles\n";
AirtimeIni193::upgradeConfigFiles();
$values = parse_ini_file(AirtimeIni193::CONF_FILE_AIRTIME, true);
$phpDir = $values['general']['airtime_dir'];
Airtime193Upgrade::InstallAirtimePhpServerCode($phpDir);
?>

View File

@ -0,0 +1,23 @@
[database]
host = localhost
dbname = airtime
dbuser = airtime
dbpass = airtime
[rabbitmq]
host = 127.0.0.1
port = 5672
user = guest
password = guest
vhost = /
[general]
api_key = AAA
web_server_user = www-data
airtime_dir = /usr/share/airtime/
base_url = localhost
base_port = 80
[soundcloud]
connection_retries = 3
time_between_retries = 60

View File

@ -0,0 +1,110 @@
bin_dir = "/usr/lib/airtime/api_clients"
#############################
## Common
#############################
# Value needed to access the API
api_key = 'AAA'
# Path to the base of the API
api_base = 'api'
# URL to get the version number of the server API
version_url = 'version/api_key/%%api_key%%'
# Hostname
base_url = 'localhost'
base_port = 80
#############################
## Config for Media Monitor
#############################
# URL to setup the media monitor
media_setup_url = 'media-monitor-setup/format/json/api_key/%%api_key%%'
# Tell Airtime the file id associated with a show instance.
upload_recorded = 'upload-recorded/format/json/api_key/%%api_key%%/fileid/%%fileid%%/showinstanceid/%%showinstanceid%%'
# URL to tell Airtime to update file's meta data
update_media_url = 'reload-metadata/format/json/api_key/%%api_key%%/mode/%%mode%%'
# URL to tell Airtime we want a listing of all files it knows about
list_all_db_files = 'list-all-files/format/json/api_key/%%api_key%%/dir_id/%%dir_id%%'
# URL to tell Airtime we want a listing of all dirs its watching (including the stor dir)
list_all_watched_dirs = 'list-all-watched-dirs/format/json/api_key/%%api_key%%'
# URL to tell Airtime we want to add watched directory
add_watched_dir = 'add-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
remove_watched_dir = 'remove-watched-dir/format/json/api_key/%%api_key%%/path/%%path%%'
# URL to tell Airtime we want to add watched directory
set_storage_dir = 'set-storage-dir/format/json/api_key/%%api_key%%/path/%%path%%'
#############################
## Config for Recorder
#############################
# URL to get the schedule of shows set to record
show_schedule_url = 'recorded-shows/format/json/api_key/%%api_key%%'
# URL to upload the recorded show's file to Airtime
upload_file_url = 'upload-file/format/json/api_key/%%api_key%%'
#number of retries to upload file if connection problem
upload_retries = 3
#time to wait between attempts to upload file if connection problem (in seconds)
upload_wait = 60
################################################################################
# Uncomment *one of the sets* of values from the API clients below, and comment
# out all the others.
################################################################################
#############################
## Config for Pypo
#############################
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
export_url = 'schedule/api_key/%%api_key%%'
get_media_url = 'get-media/file/%%file%%/api_key/%%api_key%%'
# Update whether a schedule group has begun playing.
update_item_url = 'notify-schedule-group-play/api_key/%%api_key%%/schedule_id/%%schedule_id%%'
# Update whether an audio clip is currently playing.
update_start_playing_url = 'notify-media-item-start-play/api_key/%%api_key%%/media_id/%%media_id%%/schedule_id/%%schedule_id%%'
# ???
generate_range_url = 'generate_range_dp.php'
##############
# OBP config #
##############
# URL to get the version number of the server API
#version_url = 'api/pypo/status/json'
# Schedule export path.
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
# Update whether an item has been played.
#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%'
# Update whether an item is currently playing.
#update_start_playing_url = 'api/pypo/mod/medialibrary/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%'
# ???
#generate_range_url = 'api/pypo/generate_range_dp/'

View File

@ -0,0 +1,55 @@
###########################################
# Liquidsoap config file #
###########################################
###########################################
# Output settings #
###########################################
output_sound_device = false
output_icecast_vorbis = true
output_icecast_mp3 = false
output_shoutcast = false
#output_bitrate = 128
#output_samplerate = 44100
#output_stereo = true
###########################################
# Logging settings #
###########################################
log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"
#log_level = 3
###########################################
# Icecast Stream settings #
###########################################
icecast_host = "127.0.0.1"
icecast_port = 8000
icecast_pass = "hackme"
# Icecast mountpoint names
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
# Webstream metadata settings
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
# Audio stream metadata for vorbis/ogg is disabled by default
# due to a number of client media players that disconnect
# when the metadata changes to a new track. Some versions of
# mplayer and VLC have this problem. Enable this option at your
# own risk!
output_icecast_vorbis_metadata = false
###########################################
# Shoutcast Stream settings #
###########################################
shoutcast_host = "127.0.0.1"
shoutcast_port = 9000
shoutcast_pass = "testing"
# Webstream metadata settings
shoutcast_url = "http://airtime.sourcefabric.org"
shoutcast_genre = "genre"

View File

@ -0,0 +1,21 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.

View File

@ -0,0 +1,72 @@
############################################
# pypo - configuration #
############################################
# Set the type of client you are using.
# Currently supported types:
# 1) "obp" = Open Broadcast Platform
# 2) "airtime"
#
api_client = "airtime"
############################################
# Cache Directories #
# *include* trailing slash !! #
############################################
cache_dir = '/var/tmp/airtime/pypo/cache/'
file_dir = '/var/tmp/airtime/pypo/files/'
tmp_dir = '/var/tmp/airtime/pypo/tmp/'
############################################
# Setup Directories #
# Do *not* include trailing slash !! #
############################################
cache_base_dir = '/var/tmp/airtime/pypo'
bin_dir = '/usr/lib/airtime/pypo'
log_base_dir = '/var/log/airtime'
pypo_log_dir = '/var/log/airtime/pypo'
liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap'
############################################
# Liquidsoap settings #
############################################
ls_host = '127.0.0.1'
ls_port = '1234'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# pypo preferences #
############################################
prepare_ahead = 24 #in hours
cache_for = 24 #how long to hold the cache, in hours
# Poll interval in seconds.
#
# This will rarely need to be changed because any schedule changes are
# automatically sent to pypo immediately.
#
# This is how often the poll script downloads new schedules and files from the
# server in the event that no changes are made to the schedule.
#
poll_interval = 3600 # in seconds.
# Push interval in seconds.
#
# This is how often the push script checks whether it has something new to
# push to liquidsoap.
#
# It's hard to imagine a situation where this should be more than 1 second.
#
push_interval = 1 # in seconds
# 'pre' or 'otf'. 'pre' cues while playlist preparation
# while 'otf' (on the fly) cues while loading into ls
# (needs the post_processor patch)
cue_style = 'pre'

View File

@ -0,0 +1,26 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/show-recorder'
# base path to store recordered shows at
base_recorded_files = '/var/tmp/airtime/show-recorder/'
# where the logging files live
log_dir = '/var/log/airtime/show-recorder'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
############################################
# Recorded Audio settings #
############################################
record_bitrate = 256
record_samplerate = 44100
record_channels = 2
record_sample_size = 16

View File

@ -6,9 +6,8 @@ set("log.stdout", true)
set("server.telnet", true)
set("server.telnet.port", 1234)
queue = request.queue(id="queue", length=0.5)
queue = audio_to_stereo(request.queue(id="queue", length=0.5))
queue = cue_cut(queue)
queue = audio_to_stereo(queue)
pypo_data = ref '0'
web_stream_enabled = ref false
@ -51,7 +50,6 @@ s = crossfade(s)
add_skip_command(s)
s = map_metadata(append_title, s)
if output_sound_device then
ignore(output.alsa(s))
end

View File

@ -477,7 +477,8 @@ class PypoFetch(Thread):
# most recent schedule. After that we can just wait for updates.
status, self.schedule_data = self.api_client.get_schedule()
if status == 1:
self.process_schedule(self.schedule_data , "scheduler", True)
logger.info("Bootstrap schedule received: %s", schedule_data)
self.process_schedule(schedule_data, "scheduler", True)
logger.info("Bootstrap complete: got initial copy of the schedule")
loops = 1