From 142289146ed051eb9feade9efc567aa65758c4d6 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 17 Jun 2012 22:53:19 -0400 Subject: [PATCH 1/5] better naming of function in upgrade script --- install_minimal/upgrades/airtime-2.1.1/DbUpgrade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.1.1/DbUpgrade.php b/install_minimal/upgrades/airtime-2.1.1/DbUpgrade.php index bda71b900..1d3ad410a 100644 --- a/install_minimal/upgrades/airtime-2.1.1/DbUpgrade.php +++ b/install_minimal/upgrades/airtime-2.1.1/DbUpgrade.php @@ -7,11 +7,11 @@ class AirtimeDatabaseUpgrade{ public static function start($p_dbValues){ echo "* Updating Database".PHP_EOL; - self::task0($p_dbValues); + self::runUpgradeScript($p_dbValues); echo " * Complete".PHP_EOL; } - private static function task0($p_dbValues){ + private static function runUpgradeScript($p_dbValues){ $username = $p_dbValues['database']['dbuser']; $password = $p_dbValues['database']['dbpass']; From ff35322ae9770759516731a04fbba4979fd9a90b Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 17 Jun 2012 23:24:15 -0400 Subject: [PATCH 2/5] =?UTF-8?q?CC-3988:=20Pypo:=20pypo=20doesn't=20update?= =?UTF-8?q?=20last=20schedule=20update=20time=20when=20pyp=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python_apps/pypo/pypofetch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 0919115ad..7517d3cdb 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -80,7 +80,6 @@ class PypoFetch(Thread): self.logger.info("Handling command: " + command) if command == 'update_schedule': - self.last_update_schedule_timestamp = time.time() self.schedule_data = m['schedule'] self.process_schedule(self.schedule_data) elif command == 'update_stream_setting': @@ -404,7 +403,8 @@ class PypoFetch(Thread): to the cache dir (Folder-structure: cache/YYYY-MM-DD-hh-mm-ss) - runs the cleanup routine, to get rid of unused cached files """ - def process_schedule(self, schedule_data): + def process_schedule(self, schedule_data): + self.last_update_schedule_timestamp = time.time() self.logger.debug(schedule_data) media = schedule_data["media"] media_filtered = {} From c8559cc88c65a8ba6e4f5d2ed878662daa056b5b Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 17 Jun 2012 23:38:36 -0400 Subject: [PATCH 3/5] 2.1.2 preparation --- CREDITS | 7 ++++++ VERSION | 2 +- changelog | 4 ++++ install_minimal/include/airtime-constants.php | 2 +- install_minimal/include/airtime-upgrade.php | 4 ++++ .../upgrades/airtime-2.1.2/DbUpgrade.php | 24 +++++++++++++++++++ .../airtime-2.1.2/airtime-upgrade.php | 8 +++++++ .../upgrades/airtime-2.1.2/data/upgrade.sql | 2 ++ python_apps/api_clients/api_client.py | 2 +- 9 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 install_minimal/upgrades/airtime-2.1.2/DbUpgrade.php create mode 100644 install_minimal/upgrades/airtime-2.1.2/airtime-upgrade.php create mode 100644 install_minimal/upgrades/airtime-2.1.2/data/upgrade.sql diff --git a/CREDITS b/CREDITS index f48a2d5dc..3a15126a2 100644 --- a/CREDITS +++ b/CREDITS @@ -1,3 +1,10 @@ +======= +CREDITS +======= +Version 2.1.2 +------------- +Same as previous version. + ======= CREDITS ======= diff --git a/VERSION b/VERSION index 1d69936fb..0b9f4ef5f 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ PRODUCT_ID=Airtime -PRODUCT_RELEASE=2.1.1 +PRODUCT_RELEASE=2.1.2 diff --git a/changelog b/changelog index ab1405369..579c4db28 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +2.1.2 - June 18th, 2012 + * Bug Fixes + * Fixed problem where playout engine may not retrieve program schedule after extended periods of user inactivity. + 2.1.1 - June 12th, 2012 * Changes * Add Media page will now display error message and reject uploaded file if it is corrupt diff --git a/install_minimal/include/airtime-constants.php b/install_minimal/include/airtime-constants.php index 2107ded4f..c33d25441 100644 --- a/install_minimal/include/airtime-constants.php +++ b/install_minimal/include/airtime-constants.php @@ -1,3 +1,3 @@ &1 | grep -v \"will create implicit index\""); + } +} diff --git a/install_minimal/upgrades/airtime-2.1.2/airtime-upgrade.php b/install_minimal/upgrades/airtime-2.1.2/airtime-upgrade.php new file mode 100644 index 000000000..042b92d05 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.1.2/airtime-upgrade.php @@ -0,0 +1,8 @@ + Date: Mon, 18 Jun 2012 12:24:13 -0400 Subject: [PATCH 4/5] - Add Media: fix to accept audio files with ID3 tags liquidsoap complains about --- 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 3dd72ff4b..4e37a2bad 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -888,7 +888,7 @@ Logging::log("getting media! - 2"); // Check if file is playable $command = sprintf("/usr/bin/airtime-liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))' 2>&1", $audio_file); exec($command, $output, $rv); - if ($rv != 0 || count($output) != 0) { + if ($rv != 0 || $output[0] == 'TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.') { $result = array("code" => 110, "message" => "This file appears to be corrupted and will not be added to media library."); } else { From 9ac024fa72a7d3fe052ece85245771a83bf7b427 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 19 Jun 2012 16:59:59 -0400 Subject: [PATCH 5/5] CC-3993: Validate that reporting stats are correct on Airtime PRO instances -done -if no log data for the past 24 hours, update current record with current date, and delete old records --- airtime_mvc/application/models/LiveLog.php | 311 ++++++++++++--------- 1 file changed, 175 insertions(+), 136 deletions(-) diff --git a/airtime_mvc/application/models/LiveLog.php b/airtime_mvc/application/models/LiveLog.php index b641ef6ef..5635f1e66 100644 --- a/airtime_mvc/application/models/LiveLog.php +++ b/airtime_mvc/application/models/LiveLog.php @@ -20,58 +20,77 @@ class Application_Model_LiveLog if ($rows != null) { $last_row = self::UpdateLastLogEndTime(array_pop($rows)); array_push($rows, $last_row); + $skip = false; + } else { + $sql = "SELECT * FROM CC_LIVE_LOG" + ." WHERE state = 'L'" + ." ORDER BY id"; + $rows = $con->query($sql)->fetchAll(); + + if ($rows != null) { + $last_row = self::UpdateLastLogEndTime(array_pop($rows)); + array_push($rows, $last_row); + foreach ($rows as $row) { + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); + } + } + $skip = true; } $hours = 0; $minutes = 0; $seconds = 0; - foreach ($rows as $row) { - $end = new DateTime($row['end_time']); - $start = new DateTime($row['start_time']); - $duration = $start->diff($end); - $duration = $duration->format("%H:%i:%s"); - $intervals = explode(":", $duration); - for ($i = 0; $i < sizeof($intervals); $i++) { - if (!isset($intervals[$i])) { - $intervals[$i] = 0; + if (!$skip) { + foreach ($rows as $row) { + $end = new DateTime($row['end_time']); + $start = new DateTime($row['start_time']); + $duration = $start->diff($end); + $duration = $duration->format("%H:%i:%s"); + $intervals = explode(":", $duration); + for ($i = 0; $i < sizeof($intervals); $i++) { + if (!isset($intervals[$i])) { + $intervals[$i] = 0; + } + } + + // Trim milliseconds (DateInterval does not support) + $sec = explode(".", $intervals[2]); + if (isset($sec[0])) { + $intervals[2] = $sec[0]; + } + + $seconds += $intervals[2]; + if ($seconds / 60 >= 1) { + $minutes += 1; + $seconds -= 60; + } + + $minutes += $intervals[1]; + if ($minutes / 60 >= 1) { + $hours += 1; + $minutes -= 60; + } + + $hours += $intervals[0]; + + if (!$p_keepData) { + // Delete data we just used to start a new log history + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); } } - - // Trim milliseconds (DateInterval does not support) - $sec = explode(".", $intervals[2]); - if (isset($sec[0])) { - $intervals[2] = $sec[0]; + //Trim milliseconds + $seconds = explode(".", $seconds); + if (isset($seconds[0])) { + $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); } - - $seconds += $intervals[2]; - if ($seconds / 60 >= 1) { - $minutes += 1; - $seconds -= 60; + else { + $minutes = (double)(($hours*60)+$minutes); } - - $minutes += $intervals[1]; - if ($minutes / 60 >= 1) { - $hours += 1; - $minutes -= 60; - } - - $hours += $intervals[0]; - - if (!$p_keepData) { - // Delete data we just used to start a new log history - $sql_delete = "DELETE FROM CC_LIVE_LOG" - ." WHERE id = '{$row['id']}'"; - $con->exec($sql_delete); - } - } - //Trim milliseconds - $seconds = explode(".", $seconds); - if (isset($seconds[0])) { - $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); - } - else { - $minutes = (double)(($hours*60)+$minutes); } return $minutes; } catch (Exception $e) { @@ -99,121 +118,141 @@ class Application_Model_LiveLog if ($rows != null) { $last_row = self::UpdateLastLogEndTime(array_pop($rows)); array_push($rows, $last_row); + $skip = false; + } + else { + $sql = "SELECT * FROM CC_LIVE_LOG" + ." WHERE state = 'S'" + ." ORDER BY id"; + $rows = $con->query($sql)->fetchAll(); + + if ($rows != null) { + $last_row = self::UpdateLastLogEndTime(array_pop($rows)); + array_push($rows, $last_row); + foreach ($rows as $row) { + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); + } + } + $skip = true; } $hours = 0; $minutes = 0; $seconds = 0; - /* Get all shows and tracks from cc_schedule that played - * during a scheduled state - */ - foreach ($rows as $row) { - $sql_get_tracks = "SELECT * FROM cc_schedule" - ." WHERE starts >= '{$row['start_time']}'" - ." AND starts < '{$row['end_time']}'" - ." AND file_id IS NOT NULL" - ." AND media_item_played IS TRUE"; - $tracks = $con->query($sql_get_tracks)->fetchAll(); - foreach ($tracks as $track) { - if ($track['ends'] > $row['end_time']) { - $scheduled_ends = new DateTime($row['end_time']); - $track_ends = new DateTime($track['ends']); - $extra_time = $scheduled_ends->diff($track_ends); + if (!$skip) { + /* Get all shows and tracks from cc_schedule that played + * during a scheduled state + */ + foreach ($rows as $row) { + $sql_get_tracks = "SELECT * FROM cc_schedule" + ." WHERE starts >= '{$row['start_time']}'" + ." AND starts < '{$row['end_time']}'" + ." AND file_id IS NOT NULL" + ." AND media_item_played IS TRUE"; + $tracks = $con->query($sql_get_tracks)->fetchAll(); + foreach ($tracks as $track) { + if ($track['ends'] > $row['end_time']) { + $scheduled_ends = new DateTime($row['end_time']); + $track_ends = new DateTime($track['ends']); + $extra_time = $scheduled_ends->diff($track_ends); - /* Get difference between clip_length - * and the extra time. We need to subtract - * this difference from the track's - * clip length. - */ - $clip_length = $track['clip_length']; - //Convert clip_length into seconds - $clip_length_intervals = explode(":", $clip_length); - for ($i = 0; $i < sizeof($clip_length_intervals); $i++) { - if (!isset($clip_length_intervals[$i])) { - $clip_length_intervals[$i] = 0; + /* Get difference between clip_length + * and the extra time. We need to subtract + * this difference from the track's + * clip length. + */ + $clip_length = $track['clip_length']; + //Convert clip_length into seconds + $clip_length_intervals = explode(":", $clip_length); + for ($i = 0; $i < sizeof($clip_length_intervals); $i++) { + if (!isset($clip_length_intervals[$i])) { + $clip_length_intervals[$i] = 0; + } } - } - $clip_length_seconds = $clip_length_intervals[0]*3600 + $clip_length_intervals[1]*60 + $clip_length_intervals[2]; - - $extra_time = $extra_time->format("%H:%i:%s"); - //Convert extra_time into seconds; - $extra_time_intervals = explode(":", $extra_time); - for ($i = 0; $i < sizeof($extra_time_intervals); $i++) { - if (!isset($extra_time_intervals[$i])) { - $extra_time_intervals[$i] = 0; + $clip_length_seconds = $clip_length_intervals[0]*3600 + $clip_length_intervals[1]*60 + $clip_length_intervals[2]; + + $extra_time = $extra_time->format("%H:%i:%s"); + //Convert extra_time into seconds; + $extra_time_intervals = explode(":", $extra_time); + for ($i = 0; $i < sizeof($extra_time_intervals); $i++) { + if (!isset($extra_time_intervals[$i])) { + $extra_time_intervals[$i] = 0; + } } - } - $extra_time_seconds = $extra_time_intervals[0]*3600 + $extra_time_intervals[1]*60 + $extra_time_intervals[2]; + $extra_time_seconds = $extra_time_intervals[0]*3600 + $extra_time_intervals[1]*60 + $extra_time_intervals[2]; - $clip_length_seconds -= $extra_time_seconds; - - //Convert new clip_length into "H-i-s" format - $clip_length_arr = array(); - if ($clip_length_seconds / 3600 >= 1) { - array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 3600), 2, "0", STR_PAD_LEFT)); - $clip_length_seconds -= floor($clip_length_seconds / 3600); + $clip_length_seconds -= $extra_time_seconds; + + //Convert new clip_length into "H-i-s" format + $clip_length_arr = array(); + if ($clip_length_seconds / 3600 >= 1) { + array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 3600), 2, "0", STR_PAD_LEFT)); + $clip_length_seconds -= floor($clip_length_seconds / 3600); + } + else { + array_push($clip_length_arr, "00"); + } + if ($clip_length_seconds / 60 >= 1) { + array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 60), 2, "0", STR_PAD_LEFT)); + $clip_length_seconds -= floor($clip_length_seconds / 60); + } + else { + array_push($clip_length_arr, "00"); + } + + array_push($clip_length_arr, str_pad($clip_length_seconds, 2, "0", STR_PAD_LEFT)); + $clip_length = implode(":", $clip_length_arr); } else { - array_push($clip_length_arr, "00"); - } - if ($clip_length_seconds / 60 >= 1) { - array_push($clip_length_arr, str_pad(floor($clip_length_seconds / 60), 2, "0", STR_PAD_LEFT)); - $clip_length_seconds -= floor($clip_length_seconds / 60); - } - else { - array_push($clip_length_arr, "00"); + $clip_length = $track['clip_length']; } - array_push($clip_length_arr, str_pad($clip_length_seconds, 2, "0", STR_PAD_LEFT)); - $clip_length = implode(":", $clip_length_arr); - } - else { - $clip_length = $track['clip_length']; - } - - $intervals = explode(":", $clip_length); - for ($i = 0; $i < sizeof($intervals); $i++) { - if (!isset($intervals[$i])) { - $intervals[$i] = 0; + $intervals = explode(":", $clip_length); + for ($i = 0; $i < sizeof($intervals); $i++) { + if (!isset($intervals[$i])) { + $intervals[$i] = 0; + } } - } - // Trim milliseconds (DateInteral does not support) - $sec = explode(".", $intervals[2]); - if (isset($sec[0])) { - $intervals[2] = $sec[0]; + // Trim milliseconds (DateInteral does not support) + $sec = explode(".", $intervals[2]); + if (isset($sec[0])) { + $intervals[2] = $sec[0]; + } + + $seconds += $intervals[2]; + if ($seconds / 60 >= 1) { + $minutes += 1; + $seconds -= 60; + } + + $minutes += $intervals[1]; + if ($minutes / 60 >= 1) { + $hours += 1; + $minutes -= 60; + } + + $hours += $intervals[0]; } - $seconds += $intervals[2]; - if ($seconds / 60 >= 1) { - $minutes += 1; - $seconds -= 60; + if (!$p_keepData) { + //Delete row because we do not need data anymore + $sql_delete = "DELETE FROM CC_LIVE_LOG" + ." WHERE id = '{$row['id']}'"; + $con->exec($sql_delete); } - - $minutes += $intervals[1]; - if ($minutes / 60 >= 1) { - $hours += 1; - $minutes -= 60; - } - - $hours += $intervals[0]; } - if (!$p_keepData) { - //Delete row because we do not need data anymore - $sql_delete = "DELETE FROM CC_LIVE_LOG" - ." WHERE id = '{$row['id']}'"; - $con->exec($sql_delete); + + $seconds = explode(".", $seconds); + if (isset($seconds[0])) { + $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); + } + else { + $minutes = (double)(($hours*60)+$minutes); } - } - - - $seconds = explode(".", $seconds); - if (isset($seconds[0])) { - $minutes = (double)(($hours*60)+$minutes . "." . $seconds[0]); - } - else { - $minutes = (double)(($hours*60)+$minutes); } return $minutes; } catch (Exception $e) {