From 7c1739247df0eda0256f568285147d42817a404a Mon Sep 17 00:00:00 2001 From: martin Date: Tue, 8 Mar 2011 16:44:47 -0500 Subject: [PATCH] -doctrine 2.0 alpha upgrade scripts --- application/forms/Preferences.php | 1 - application/models/Nowplaying.php | 3 ++ application/models/Shows.php | 1 + .../Version20110308003959.php | 8 ++-- install/airtime-upgrade.php | 2 +- public/js/playlist/nowplayingdatagrid.js | 3 ++ pypo/api_clients/api_client.py | 41 +++---------------- pypo/scripts/ls_lib.liq | 4 +- 8 files changed, 20 insertions(+), 43 deletions(-) diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index b776b8096..6b6903936 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -38,7 +38,6 @@ class Application_Form_Preferences extends Zend_Form $stream_format->setLabel('Stream Label:'); $stream_format->setMultiOptions(array("Artist - Title", "Show - Artist - Title", - "Show", "Station name - Show name")); $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); $this->addElement($stream_format); diff --git a/application/models/Nowplaying.php b/application/models/Nowplaying.php index 5602945f6..726825a5f 100644 --- a/application/models/Nowplaying.php +++ b/application/models/Nowplaying.php @@ -82,6 +82,9 @@ class Application_Model_Nowplaying $type = "n"; } + if (strtotime($item['item_ends']) > strtotime($item['show_ends'])) + $type = "over"; + array_push($data, array($type, $item["item_starts"], $item["item_starts"], $item["item_ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], $item["album_title"], $item["playlist_name"], $item["show_name"], $item["instance_id"])); } } diff --git a/application/models/Shows.php b/application/models/Shows.php index c55becf5a..c36a987b2 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -788,6 +788,7 @@ class Show_DAL{ ." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')" ." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')" ." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))" + //checking for st.starts IS NULL so that the query also returns shows that do not have any items scheduled. ." AND (st.starts < si.ends OR st.starts IS NULL)" ." ORDER BY st.starts"; diff --git a/install/DoctrineMigrations/Version20110308003959.php b/install/DoctrineMigrations/Version20110308003959.php index bea197010..074e8af79 100644 --- a/install/DoctrineMigrations/Version20110308003959.php +++ b/install/DoctrineMigrations/Version20110308003959.php @@ -9,13 +9,13 @@ class Version20110308003959 extends AbstractMigration { public function up(Schema $schema) { - $table = $schema->createTable('users'); - $table->addColumn('username', 'string'); - $table->addColumn('password', 'string'); + $table = $this->getTable("cc_show_instances"); + $table->addColumn("record", "boolean"); } public function down(Schema $schema) { - $schema->dropTable('users'); + $table = $this->getTable("cc_show_instances"); + $table->dropColumn("record"); } } diff --git a/install/airtime-upgrade.php b/install/airtime-upgrade.php index 707cd30e3..f582604f7 100644 --- a/install/airtime-upgrade.php +++ b/install/airtime-upgrade.php @@ -2,6 +2,6 @@ $dir = __DIR__; -$command = "php $dir/../library/doctrine/migrations/doctrine-migrations.phar --configuration=$dir/DoctrineMigrations/migrations.xml --db-configuration=$dir/../library/doctrine/migrations/migrations-db.php migrations:status"; +$command = "php $dir/../library/doctrine/migrations/doctrine-migrations.phar --configuration=$dir/DoctrineMigrations/migrations.xml --db-configuration=$dir/../library/doctrine/migrations/migrations-db.php --no-interaction migrations:diff"; system($command); diff --git a/public/js/playlist/nowplayingdatagrid.js b/public/js/playlist/nowplayingdatagrid.js index b1ca520be..9d4151e2f 100644 --- a/public/js/playlist/nowplayingdatagrid.js +++ b/public/js/playlist/nowplayingdatagrid.js @@ -128,6 +128,9 @@ function createDataGrid(){ $(nRow).addClass("playing-list"); if (aData[0] == "c") $(nRow).attr("class", "playing-song"); + else if (aData[0] == "over"){ + //$(nRow).attr("class", "over-booked-song"); + } return nRow; }, "fnDrawCallback": function(oSettings){ diff --git a/pypo/api_clients/api_client.py b/pypo/api_clients/api_client.py index b7023d349..5fd04b522 100644 --- a/pypo/api_clients/api_client.py +++ b/pypo/api_clients/api_client.py @@ -111,6 +111,7 @@ class AirTimeApiClient(ApiClientInterface): def __get_airtime_version(self, verbose = True): logger = logging.getLogger() url = self.config["base_url"] + self.config["api_base"] + self.config["version_url"] + logger.debug("Trying to contact %s", url) url = url.replace("%%api_key%%", self.config["api_key"]) try: @@ -159,7 +160,6 @@ class AirTimeApiClient(ApiClientInterface): for pkey in sorted(schedule.iterkeys()): logger.debug("Playlist #%s",str(count)) count+=1 - #logger.info("found playlist at %s", pkey) playlist = schedule[pkey] for item in playlist["medias"]: filename = urlparse(item["uri"]) @@ -210,21 +210,18 @@ class AirTimeApiClient(ApiClientInterface): # Construct the URL export_url = self.config["base_url"] + self.config["api_base"] + self.config["export_url"] - #logger.debug("Exporting schedule using URL: "+export_url) # Insert the start and end times into the URL - export_url = export_url.replace('%%api_key%%', self.config["api_key"]) export_url = export_url.replace('%%from%%', range['start']) export_url = export_url.replace('%%to%%', range['end']) logger.info("Fetching schedule from %s", export_url) - + export_url = export_url.replace('%%api_key%%', self.config["api_key"]) + response = "" status = 0 try: response_json = urllib.urlopen(export_url).read() - #logger.debug("%s", response_json) response = json.loads(response_json) - #logger.info("export status %s", response['check']) status = response['check'] except Exception, e: print e @@ -242,12 +239,9 @@ class AirTimeApiClient(ApiClientInterface): # toRemove.append(pkey) # else: # break - # #logger.debug("Remove keys: %s", toRemove) # for index in toRemove: # del schedule[index] - # #logger.debug("Schedule dict: %s", schedule) #except Exception, e: - # logger.debug("'Ignore Past Playlists' feature not supported by API: %s", e) #response["playlists"] = schedule return status, response @@ -257,12 +251,10 @@ class AirTimeApiClient(ApiClientInterface): logger = logging.getLogger() try: + logger.info("try to download from %s to %s", src, dst) src = src + "/api_key/" + self.config["api_key"] - logger.debug("try to download from %s to %s", src, dst) # check if file exists already before downloading again filename, headers = urllib.urlretrieve(src, dst) - - logger.info("downloaded %s to %s", src, dst) except Exception, e: logger.error("%s", e) @@ -276,8 +268,8 @@ class AirTimeApiClient(ApiClientInterface): schedule_id = playlist["schedule_id"] url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"] url = url.replace("%%schedule_id%%", str(schedule_id)) - url = url.replace("%%api_key%%", self.config["api_key"]) logger.debug(url) + url = url.replace("%%api_key%%", self.config["api_key"]) try: response = urllib.urlopen(url) @@ -304,8 +296,8 @@ class AirTimeApiClient(ApiClientInterface): url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"] url = url.replace("%%media_id%%", str(media_id)) url = url.replace("%%schedule_id%%", str(schedule_id)) - url = url.replace("%%api_key%%", self.config["api_key"]) logger.debug(url) + url = url.replace("%%api_key%%", self.config["api_key"]) response = urllib.urlopen(url) response = json.loads(response.read()) logger.info("API-Status %s", response['status']) @@ -316,27 +308,6 @@ class AirTimeApiClient(ApiClientInterface): return response - - def generate_range_dp(self): - pass - #logger = logging.getLogger() - # - #url = self.api_url + 'schedule/generate_range_dp.php' - # - #try: - # response = urllib.urlopen(url, self.api_auth) - # response = json.loads(response.read()) - # logger.debug("Trying to contact %s", url) - # logger.info("API-Status %s", response['status']) - # logger.info("API-Message %s", response['message']) - # - #except Exception, e: - # print e - # api_status = False - # logger.critical("Unable to handle the request - %s", e) - # - #return response - def get_liquidsoap_data(self, pkey, schedule): logger = logging.getLogger() playlist = schedule[pkey] diff --git a/pypo/scripts/ls_lib.liq b/pypo/scripts/ls_lib.liq index b9f227fda..f9cfd58ce 100644 --- a/pypo/scripts/ls_lib.liq +++ b/pypo/scripts/ls_lib.liq @@ -7,9 +7,9 @@ end def append_title(m) = if !stream_metadata_type == 1 then [("artist","#{!show_name} - #{m['title']}")] + #elsif !stream_metadata_type == 2 then + # [("artist", ""), ("title", !show_name)] elsif !stream_metadata_type == 2 then - [("artist", ""), ("title", !show_name)] - elsif !stream_metadata_type == 3 then [("artist",!station_name), ("title", !show_name)] else []