Merge branch '2.2.x' of dev.sourcefabric.org:airtime into 2.2.x

This commit is contained in:
Martin Konecny 2012-10-29 16:29:20 -04:00
commit 5f0fd0ef09
8 changed files with 350 additions and 328 deletions

View File

@ -661,6 +661,7 @@ SQL;
$data["media"][$switch_start]['start'] = $switch_start; $data["media"][$switch_start]['start'] = $switch_start;
$data["media"][$switch_start]['end'] = $switch_start; $data["media"][$switch_start]['end'] = $switch_start;
$data["media"][$switch_start]['event_type'] = "switch_off"; $data["media"][$switch_start]['event_type'] = "switch_off";
$data["media"][$kick_start]['type'] = "event";
$data["media"][$switch_start]['independent_event'] = true; $data["media"][$switch_start]['independent_event'] = true;
} }
} }

View File

@ -26,7 +26,10 @@ class Application_Model_Soundcloud
public function uploadTrack($filepath, $filename, $description, public function uploadTrack($filepath, $filename, $description,
$tags=array(), $release=null, $genre=null) $tags=array(), $release=null, $genre=null)
{ {
if ($this->getToken()) {
if (!$this->getToken()) {
throw new NoSoundCloundToken();
}
if (count($tags)) { if (count($tags)) {
$tags = join(" ", $tags); $tags = join(" ", $tags);
$tags = $tags." ".Application_Model_Preference::GetSoundCloudTags(); $tags = $tags." ".Application_Model_Preference::GetSoundCloudTags();
@ -82,9 +85,7 @@ class Application_Model_Soundcloud
); );
return $response; return $response;
} else {
throw new NoSoundCloundToken();
}
} }
public static function uploadSoundcloud($id) public static function uploadSoundcloud($id)

View File

@ -92,5 +92,13 @@ if ($item['type'] == 2) {
<?php endforeach; ?> <?php endforeach; ?>
<?php else : ?> <?php else : ?>
<li class="spl_empty">Empty playlist</li> <li class="spl_empty">
<?php
if ($this->obj instanceof Application_Model_Block) {
echo 'Empty smart block';
} else {
echo 'Empty playlist';
}
?>
</li>
<?php endif; ?> <?php endif; ?>

View File

@ -339,10 +339,22 @@ var AIRTIME = (function(AIRTIME){
}); });
}; };
mod.jumpToCurrentTrack = function() {
var $scroll = $sbContent.find(".dataTables_scrolling");
var scrolled = $scroll.scrollTop();
var scrollingTop = $scroll.offset().top;
var oTable = $('#show_builder_table').dataTable();
var current = $sbTable.find("."+NOW_PLAYING_CLASS);
var currentTop = current.offset().top;
$scroll.scrollTop(currentTop - scrollingTop + scrolled);
}
mod.builderDataTable = function() { mod.builderDataTable = function() {
$sbContent = $('#show_builder'); $sbContent = $('#show_builder');
$lib = $("#library_content"), $lib = $("#library_content"),
$sbTable = $sbContent.find('table'); $sbTable = $sbContent.find('table');
var isInitialized = false;
oSchedTable = $sbTable.dataTable( { oSchedTable = $sbTable.dataTable( {
"aoColumns": [ "aoColumns": [
@ -636,6 +648,13 @@ var AIRTIME = (function(AIRTIME){
$("#draggingContainer").remove(); $("#draggingContainer").remove();
}, },
"fnDrawCallback": function fnBuilderDrawCallback(oSettings, json) { "fnDrawCallback": function fnBuilderDrawCallback(oSettings, json) {
if (!isInitialized) {
if ($(this).find("."+NOW_PLAYING_CLASS).length > 0) {
mod.jumpToCurrentTrack();
}
}
isInitialized = true;
var wrapperDiv, var wrapperDiv,
markerDiv, markerDiv,
$td, $td,
@ -1021,7 +1040,7 @@ var AIRTIME = (function(AIRTIME){
if (AIRTIME.button.isDisabled('icon-step-forward', true) === true) { if (AIRTIME.button.isDisabled('icon-step-forward', true) === true) {
return; return;
} }
/*
var $scroll = $sbContent.find(".dataTables_scrolling"), var $scroll = $sbContent.find(".dataTables_scrolling"),
scrolled = $scroll.scrollTop(), scrolled = $scroll.scrollTop(),
scrollingTop = $scroll.offset().top, scrollingTop = $scroll.offset().top,
@ -1029,6 +1048,8 @@ var AIRTIME = (function(AIRTIME){
currentTop = current.offset().top; currentTop = current.offset().top;
$scroll.scrollTop(currentTop - scrollingTop + scrolled); $scroll.scrollTop(currentTop - scrollingTop + scrolled);
*/
mod.jumpToCurrentTrack();
}); });
//delete overbooked tracks. //delete overbooked tracks.

View File

@ -133,7 +133,8 @@ AIRTIME = (function(AIRTIME) {
$builder.find(dateEndId).datepicker(oBaseDatePickerSettings); $builder.find(dateEndId).datepicker(oBaseDatePickerSettings);
$builder.find(timeEndId).timepicker(oBaseTimePickerSettings); $builder.find(timeEndId).timepicker(oBaseTimePickerSettings);
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId,
dateEndId, timeEndId);
AIRTIME.showbuilder.fnServerData.start = oRange.start; AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end; AIRTIME.showbuilder.fnServerData.end = oRange.end;
@ -144,7 +145,8 @@ AIRTIME = (function(AIRTIME) {
$libWrapper = $lib.find("#library_display_wrapper"); $libWrapper = $lib.find("#library_display_wrapper");
$libWrapper.prepend($libClose); $libWrapper.prepend($libClose);
$builder.find('.dataTables_scrolling').css("max-height", widgetHeight - 95); $builder.find('.dataTables_scrolling').css("max-height",
widgetHeight - 95);
$builder.on("click", "#sb_submit", showSearchSubmit); $builder.on("click", "#sb_submit", showSearchSubmit);
@ -154,25 +156,26 @@ AIRTIME = (function(AIRTIME) {
// reset timestamp to redraw the cursors. // reset timestamp to redraw the cursors.
AIRTIME.showbuilder.resetTimestamp(); AIRTIME.showbuilder.resetTimestamp();
$lib.show() $lib.show().width(Math.floor(screenWidth * 0.48));
.width(Math.floor(screenWidth * 0.48));
$builder.width(Math.floor(screenWidth * 0.48)) $builder.width(Math.floor(screenWidth * 0.48)).find("#sb_edit")
.find("#sb_edit") .remove().end().find("#sb_date_start")
.remove() .css("margin-left", 0).end();
.end()
.find("#sb_date_start")
.css("margin-left", 0)
.end();
schedTable.fnDraw(); schedTable.fnDraw();
$.ajax( { $.ajax( {
url : "/usersettings/set-now-playing-screen-settings", url : "/usersettings/set-now-playing-screen-settings",
type : "POST", type : "POST",
data: {settings : {library : true}, format: "json"}, data : {
settings : {
library : true
},
format : "json"
},
dataType : "json", dataType : "json",
success: function(){} success : function() {
}
}); });
}); });
@ -180,13 +183,9 @@ AIRTIME = (function(AIRTIME) {
var schedTable = $("#show_builder_table").dataTable(); var schedTable = $("#show_builder_table").dataTable();
$lib.hide(); $lib.hide();
$builder.width(screenWidth) $builder.width(screenWidth).find(".sb-timerange").prepend(
.find(".sb-timerange") $toggleLib).find("#sb_date_start").css("margin-left", 30)
.prepend($toggleLib) .end().end();
.find("#sb_date_start")
.css("margin-left", 30)
.end()
.end();
$toggleLib.removeClass("ui-state-hover"); $toggleLib.removeClass("ui-state-hover");
schedTable.fnDraw(); schedTable.fnDraw();
@ -194,26 +193,35 @@ AIRTIME = (function(AIRTIME) {
$.ajax( { $.ajax( {
url : "/usersettings/set-now-playing-screen-settings", url : "/usersettings/set-now-playing-screen-settings",
type : "POST", type : "POST",
data: {settings : {library : false}, format: "json"}, data : {
settings : {
library : false
},
format : "json"
},
dataType : "json", dataType : "json",
success: function(){} success : function() {
}
}); });
}); });
$builder.find('legend').click(function(ev, item){ $builder.find('legend').click(
function(ev, item) {
if ($fs.hasClass("closed")) { if ($fs.hasClass("closed")) {
$fs.removeClass("closed"); $fs.removeClass("closed");
$builder.find('.dataTables_scrolling').css("max-height", widgetHeight - 150); $builder.find('.dataTables_scrolling').css(
} "max-height", widgetHeight - 150);
else { } else {
$fs.addClass("closed"); $fs.addClass("closed");
// set defaults for the options. // set defaults for the options.
$fs.find('select').val(0); $fs.find('select').val(0);
$fs.find('input[type="checkbox"]').attr("checked", false); $fs.find('input[type="checkbox"]').attr("checked",
$builder.find('.dataTables_scrolling').css("max-height", widgetHeight - 110); false);
$builder.find('.dataTables_scrolling').css(
"max-height", widgetHeight - 110);
} }
}); });
@ -231,7 +239,8 @@ AIRTIME = (function(AIRTIME) {
$builder.on("change", '#sb_show_filter', function(ev) { $builder.on("change", '#sb_show_filter', function(ev) {
if ($(this).val() !== 0) { if ($(this).val() !== 0) {
$(ev.delegateTarget).find('#sb_my_shows').attr("checked", false); $(ev.delegateTarget).find('#sb_my_shows')
.attr("checked", false);
} }
showSearchSubmit(); showSearchSubmit();
@ -239,11 +248,8 @@ AIRTIME = (function(AIRTIME) {
}); });
function checkScheduleUpdates() { function checkScheduleUpdates() {
var data = {}, var data = {}, oTable = $('#show_builder_table').dataTable(), fn = oTable
oTable = $('#show_builder_table').dataTable(), .fnSettings().fnServerData, start = fn.start, end = fn.end;
fn = oTable.fnSettings().fnServerData,
start = fn.start,
end = fn.end;
data["format"] = "json"; data["format"] = "json";
data["start"] = start; data["start"] = start;

View File

@ -20,6 +20,11 @@ import traceback
AIRTIME_VERSION = "2.2.0" AIRTIME_VERSION = "2.2.0"
# TODO : Place these functions in some common module. Right now, media
# monitor uses the same functions and it would be better to reuse them
# instead of copy pasting them around
def to_unicode(obj, encoding='utf-8'): def to_unicode(obj, encoding='utf-8'):
if isinstance(obj, basestring): if isinstance(obj, basestring):
if not isinstance(obj, unicode): if not isinstance(obj, unicode):
@ -39,7 +44,7 @@ def convert_dict_value_to_utf8(md):
# Airtime API Client # Airtime API Client
################################################################################ ################################################################################
class AirtimeApiClient(): class AirtimeApiClient(object):
# This is a little hacky fix so that I don't have to pass the config object # This is a little hacky fix so that I don't have to pass the config object
# everywhere where AirtimeApiClient needs to be initialized # everywhere where AirtimeApiClient needs to be initialized
@ -422,15 +427,13 @@ class AirtimeApiClient():
def send_media_monitor_requests(self, action_list, dry=False): def send_media_monitor_requests(self, action_list, dry=False):
""" """
Send a gang of media monitor events at a time. actions_list is a list Send a gang of media monitor events at a time. actions_list is a
of dictionaries where every dictionary is representing an action. Every list of dictionaries where every dictionary is representing an
action dict must contain a 'mode' key that says what kind of action it action. Every action dict must contain a 'mode' key that says
is and an optional 'is_record' key that says whether the show was what kind of action it is and an optional 'is_record' key that
recorded or not. The value of this key does not matter, only if it's says whether the show was recorded or not. The value of this key
present or not. does not matter, only if it's present or not.
""" """
logger = self.logger
try:
url = self.construct_url('reload_metadata_group') url = self.construct_url('reload_metadata_group')
# We are assuming that action_list is a list of dictionaries such # We are assuming that action_list is a list of dictionaries such
# that every dictionary represents the metadata of a file along # that every dictionary represents the metadata of a file along
@ -464,11 +467,6 @@ class AirtimeApiClient():
response = self.get_response_from_server(req) response = self.get_response_from_server(req)
response = json.loads(response) response = json.loads(response)
return response return response
except ValueError: raise
except Exception, e:
logger.error('Exception: %s', e)
logger.error("traceback: %s", traceback.format_exc())
raise
#returns a list of all db files for a given directory in JSON format: #returns a list of all db files for a given directory in JSON format:
#{"files":["path/to/file1", "path/to/file2"]} #{"files":["path/to/file1", "path/to/file2"]}

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import traceback
""" """
Python part of radio playout (pypo) Python part of radio playout (pypo)
@ -102,6 +103,24 @@ class Notify:
logger.debug('# Calling server to update webstream data #') logger.debug('# Calling server to update webstream data #')
logger.debug('#################################################') logger.debug('#################################################')
response = self.api_client.notify_webstream_data(data, media_id) response = self.api_client.notify_webstream_data(data, media_id)
logger.debug("Response: " + json.dumps(response))
def run_with_options(self, options):
if options.error and options.stream_id:
self.notify_liquidsoap_status(options.error, options.stream_id, options.time)
elif options.connect and options.stream_id:
self.notify_liquidsoap_status("OK", options.stream_id, options.time)
elif options.source_name and options.source_status:
self.notify_source_status(options.source_name, options.source_status)
elif options.webstream:
self.notify_webstream_data(options.webstream, options.media_id)
elif options.media_id:
self.notify_media_start_playing(options.media_id)
elif options.liquidsoap_started:
self.notify_liquidsoap_started()
else:
logger.debug("Unrecognized option in options(%s). Doing nothing" \
% str(options))
if __name__ == '__main__': if __name__ == '__main__':
@ -112,41 +131,9 @@ if __name__ == '__main__':
print '#########################################' print '#########################################'
# initialize # initialize
if options.error and options.stream_id:
try: try:
n = Notify() n = Notify()
n.notify_liquidsoap_status(options.error, options.stream_id, options.time) n.run_with_options(options)
except Exception, e: except Exception as e:
print e print( traceback.format_exc() )
elif options.connect and options.stream_id:
try:
n = Notify()
n.notify_liquidsoap_status("OK", options.stream_id, options.time)
except Exception, e:
print e
elif options.source_name and options.source_status:
try:
n = Notify()
n.notify_source_status(options.source_name, options.source_status)
except Exception, e:
print e
elif options.webstream:
try:
n = Notify()
n.notify_webstream_data(options.webstream, options.media_id)
except Exception, e:
print e
elif options.media_id:
try:
n = Notify()
n.notify_media_start_playing(options.media_id)
except Exception, e:
print e
elif options.liquidsoap_started:
try:
n = Notify()
n.notify_liquidsoap_started()
except Exception, e:
print e