From c301cd525693ab6839c2e4ff27b9c50fa1ef21e0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 23 Mar 2012 12:49:50 -0400 Subject: [PATCH] cc-3476: dynamic timeout --- airtime_mvc/application/models/DateHelper.php | 12 ++++++++++++ airtime_mvc/application/models/Schedule.php | 9 ++++++--- python_apps/pypo/pypopush.py | 7 +++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/DateHelper.php b/airtime_mvc/application/models/DateHelper.php index 7f574cbbc..504ad9e9e 100644 --- a/airtime_mvc/application/models/DateHelper.php +++ b/airtime_mvc/application/models/DateHelper.php @@ -292,5 +292,17 @@ class Application_Model_DateHelper return $p_dateString; return self::ConvertToUtcDateTime($p_dateString)->format($p_format); } + + /* + * Example input: "00:02:32.746562". Output is a DateInterval object + * representing that 2 minute, 32.746562 second interval. + * + */ + public static function getDateIntervalFromString($p_interval){ + list($hour_min_sec, $subsec) = explode(".", $p_interval); + list($hour, $min, $sec) = explode(":", $hour_min_sec); + + return new DateInterval("PT{$hour}H{$min}M{$sec}S"); + } } diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 5a1a304a9..718ab5895 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -645,16 +645,19 @@ class Application_Model_Schedule { $uri = $storedFile->getFilePath(); $showEndDateTime = new DateTime($item["show_end"], $utcTimeZone); + $trackStartDateTime = new DateTime($item["start"], $utcTimeZone); $trackEndDateTime = new DateTime($item["end"], $utcTimeZone); /* Note: cue_out and end are always the same. */ /* TODO: Not all tracks will have "show_end" */ if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){ - $diff = $trackEndDateTime->getTimestamp() - $showEndDateTime->getTimestamp(); - //assuming ends takes cue_out into assumption - $item["cue_out"] = $item["cue_out"] - $diff; + $di = $trackStartDateTime->diff($showEndDateTime); + + $item["cue_out"] = $di->format("%H:%i:%s").".000"; } + + $start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]); $data["media"][$start] = array( diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 5aa14a233..7a6b0bd92 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -161,11 +161,14 @@ class PypoPush(Thread): #Everything OK for this iteration. pass else: - #A different item has been scheduled at the same time! + #A different item has been scheduled at the same time! Need to remove + #all tracks from the Liquidsoap queue starting at this point, and re-add + #them. problem_at_iteration = iteration break else: - #There are no more items scheduled for this time! + #There are no more items scheduled for this time! The user has shortened + #the playlist, so we simply need to remove tracks from the queue. problem_at_iteration = iteration break iteration+=1