Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-09-18 17:22:22 -04:00
commit b69f3288d3
13 changed files with 56 additions and 32 deletions

View File

@ -783,6 +783,8 @@ class ScheduleController extends Zend_Controller_Action
$data['add_show_instance_id']); $data['add_show_instance_id']);
if ($success) { if ($success) {
$scheduler = new Application_Model_Scheduler();
$scheduler->removeGaps($data['add_show_instance_id']);
$this->view->addNewShow = true; $this->view->addNewShow = true;
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} else { } else {

View File

@ -1291,6 +1291,10 @@ SQL;
} else { } else {
$qry->add($spCriteria, $spCriteriaValue, $spCriteriaModifier); $qry->add($spCriteria, $spCriteriaValue, $spCriteriaModifier);
} }
if ($spCriteriaModifier == Criteria::NOT_ILIKE || $spCriteriaModifier == Criteria::NOT_EQUAL) {
$qry->addOr($spCriteria, null, Criteria::ISNULL);
}
} catch (Exception $e) { } catch (Exception $e) {
Logging::info($e); Logging::info($e);
} }

View File

@ -331,7 +331,7 @@ class Application_Model_Scheduler
* This function squeezes all items of a show together so that * This function squeezes all items of a show together so that
* there are no gaps between them. * there are no gaps between them.
*/ */
private function removeGaps($showInstance, $exclude=null) public function removeGaps($showInstance, $exclude=null)
{ {
Logging::info("removing gaps from show instance #".$showInstance); Logging::info("removing gaps from show instance #".$showInstance);

View File

@ -187,12 +187,12 @@ SQL;
if ($diff != 0) { if ($diff != 0) {
$sql = <<<SQL $sql = <<<SQL
UPDATE cc_schedule UPDATE cc_schedule
SET starts = starts + INTERVAL :diff1 SECOND, SET starts = starts + :diff1::INTERVAL SECOND,
ends = ends + INTERVAL :diff2 SECOND ends = ends + :diff2::INTERVAL SECOND
WHERE instance_id = :instanceId WHERE instance_id = :instanceId
SQL; SQL;
Application_Common_Database::prepareAndExecute($sql, Application_Common_Database::prepareAndExecute($sql,
array( array(
':diff1' => $diff, ':diff1' => $diff,
':diff2' => $diff, ':diff2' => $diff,
':instanceId' => $instance_id ), 'execute'); ':instanceId' => $instance_id ), 'execute');
@ -345,7 +345,7 @@ SQL;
//$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; //$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
$sql = "SELECT timestamp :ends + interval :deltaDays + interval :deltaTime"; $sql = "SELECT timestamp :ends + interval :deltaDays + interval :deltaTime";
$now_ends = Application_Common_Database::prepareAndExecute($sql, $now_ends = Application_Common_Database::prepareAndExecute($sql,
array(':ends' => $ends, array(':ends' => $ends,
':deltaDays' => "$deltaDay days", ':deltaDays' => "$deltaDay days",
':deltaTime' => "{$hours}:{$mins}"), 'column' ':deltaTime' => "{$hours}:{$mins}"), 'column'
@ -765,7 +765,7 @@ WHERE si.ends < :timeNow::TIMESTAMP
AND si.modified_instance = 'f' AND si.modified_instance = 'f'
ORDER BY si.ends DESC LIMIT 1; ORDER BY si.ends DESC LIMIT 1;
SQL; SQL;
$id = Application_Common_Database( $sql, array( $id = Application_Common_Database( $sql, array(
':timeNow' => $p_timeNow ), 'column' ); ':timeNow' => $p_timeNow ), 'column' );
return ($id ? new Application_Model_ShowInstance($id) : null ); return ($id ? new Application_Model_ShowInstance($id) : null );
@ -818,7 +818,7 @@ SELECT count(*) AS cnt
FROM cc_show_instances FROM cc_show_instances
WHERE ends < :day WHERE ends < :day
SQL; SQL;
return Application_Common_Database::prepareAndExecute( $sql, return Application_Common_Database::prepareAndExecute( $sql,
array( ':day' => $day ), 'column' ); array( ':day' => $day ), 'column' );
} }

View File

@ -1,9 +1,9 @@
<?php <?php
define('UTYPE_HOST', 'H'); define('UTYPE_HOST' , 'H');
define('UTYPE_ADMIN', 'A'); define('UTYPE_ADMIN' , 'A');
define('UTYPE_GUEST', 'G'); define('UTYPE_GUEST' , 'G');
define('UTYPE_PROGRAM_MANAGER', 'P'); define('UTYPE_PROGRAM_MANAGER' , 'P');
class Application_Model_User class Application_Model_User
{ {

View File

@ -17,12 +17,12 @@ class BitrateFormatter
public function format() public function format()
{ {
$Kbps = bcdiv($this->_bitrate, 1000, 0); $kbps = bcdiv($this->_bitrate, 1000, 0);
if ($Kbps == 0) { if ($kbps == 0) {
return ""; return "";
} else { } else {
return "{$Kbps} Kbps"; return "$kbps Kbps";
} }
} }
} }

View File

@ -366,7 +366,7 @@ var AIRTIME = (function(AIRTIME){
//and verify whether they can be previewed by the browser or not. If not //and verify whether they can be previewed by the browser or not. If not
//then the playlist element is greyed out //then the playlist element is greyed out
mod.validatePlaylistElements = function(){ mod.validatePlaylistElements = function(){
$.each($(".big_play"), function(index, value){ $.each($(".big_play ui-icon-play"), function(index, value){
if ($(value).attr('blockId') === undefined) { if ($(value).attr('blockId') === undefined) {
var mime = $(value).attr("data-mime-type"); var mime = $(value).attr("data-mime-type");
if (isAudioSupported(mime)) { if (isAudioSupported(mime)) {

View File

@ -15,9 +15,10 @@ $(document).ready(function(){
close: doNotShowPopup, close: doNotShowPopup,
buttons: [ buttons: [
{ {
id: "remind_me", id: "remind_me",
text: "Remind me in 1 week", text: "Remind me in 1 week",
click: function() { "class": "btn",
click: function() {
var url = '/Usersettings/remindme'; var url = '/Usersettings/remindme';
$.ajax({ $.ajax({
url: url, url: url,
@ -29,6 +30,7 @@ $(document).ready(function(){
{ {
id: "remind_never", id: "remind_never",
text: "Remind me never", text: "Remind me never",
"class": "btn",
click: function() { click: function() {
var url ='/Usersettings/remindme-never'; var url ='/Usersettings/remindme-never';
$.ajax({ $.ajax({
@ -41,6 +43,7 @@ $(document).ready(function(){
{ {
id: "help_airtime", id: "help_airtime",
text: "Yes, help Airtime", text: "Yes, help Airtime",
"class": "btn",
click: function() { click: function() {
$("#register-form").submit(); $("#register-form").submit();
} }

View File

@ -255,8 +255,8 @@ function eventRender(event, element, view) {
} }
//add scheduled show content empty icon //add scheduled show content empty icon
addIcon = checkEmptyShowStatus(event); //addIcon = checkEmptyShowStatus(event);
if (!addIcon) { //if (!addIcon) {
if (view.name === 'agendaDay' || view.name === 'agendaWeek') { if (view.name === 'agendaDay' || view.name === 'agendaWeek') {
if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) { if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) {
if (event.soundcloud_id === -1) { if (event.soundcloud_id === -1) {
@ -282,7 +282,7 @@ function eventRender(event, element, view) {
} }
} }
} }
} //}
//rebroadcast icon //rebroadcast icon
if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) { if((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.rebroadcast === 1) {
@ -518,6 +518,7 @@ function addQtipToSCIcons(ele){
* This gets checked when we are deciding if the show-empty icon should be added * This gets checked when we are deciding if the show-empty icon should be added
* at the beginning of an event render callback. * at the beginning of an event render callback.
*/ */
/*
function checkEmptyShowStatus(e) { function checkEmptyShowStatus(e) {
var currDate = new Date(); var currDate = new Date();
var endTime; var endTime;
@ -541,6 +542,7 @@ function checkEmptyShowStatus(e) {
return showOver; return showOver;
} }
} }
*/
//Alert the error and reload the page //Alert the error and reload the page
//this function is used to resolve concurrency issue //this function is used to resolve concurrency issue
@ -552,7 +554,7 @@ function alertShowErrorAndReload(){
$(document).ready(function(){ $(document).ready(function(){
setInterval( "checkSCUploadStatus()", 5000 ); setInterval( "checkSCUploadStatus()", 5000 );
setInterval( "getCurrentShow()", 5000 ); setInterval( "getCurrentShow()", 5000 );
setInterval( "checkEmptyShowStatus()", 5000 ); //setInterval( "checkEmptyShowStatus()", 5000 );
}); });
var view_name; var view_name;

View File

@ -2,13 +2,12 @@
from kombu.messaging import Exchange, Queue, Consumer from kombu.messaging import Exchange, Queue, Consumer
from kombu.connection import BrokerConnection from kombu.connection import BrokerConnection
from os.path import normpath from os.path import normpath
from mutagen.easymp4 import EasyMP4KeyError
import json import json
import os import os
import copy import copy
from media.monitor.exceptions import BadSongFile from media.monitor.exceptions import BadSongFile, InvalidMetadataElement
from media.monitor.metadata import Metadata from media.monitor.metadata import Metadata
from media.monitor.log import Loggable from media.monitor.log import Loggable
from media.monitor.syncdb import AirtimeDB from media.monitor.syncdb import AirtimeDB
@ -118,7 +117,7 @@ class AirtimeMessageReceiver(Loggable):
try: Metadata.write_unsafe(path=md_path, md=msg) try: Metadata.write_unsafe(path=md_path, md=msg)
except BadSongFile as e: except BadSongFile as e:
self.logger.info("Cannot find metadata file: '%s'" % e.path) self.logger.info("Cannot find metadata file: '%s'" % e.path)
except EasyMP4KeyError as e: except InvalidMetadataElement as e:
self.logger.info("Metadata instance not supported for this file '%s'" \ self.logger.info("Metadata instance not supported for this file '%s'" \
% e.path) % e.path)
self.logger.info(str(e)) self.logger.info(str(e))

View File

@ -48,3 +48,13 @@ class NoDirectoryInAirtime(Exception):
def __str__(self): def __str__(self):
return "Directory '%s' does not exist in Airtime.\n \ return "Directory '%s' does not exist in Airtime.\n \
However: %s do exist." % (self.path, self.does_exist) However: %s do exist." % (self.path, self.does_exist)
class InvalidMetadataElement(Exception):
def __init__(self, parent, key, path):
self.parent = parent
self.key = key
self.path = path
def __str__(self):
return "InvalidMetadataElement: (key,path) = (%s,%s)" \
% (self.key, self.path)

View File

@ -2,10 +2,11 @@
import mutagen import mutagen
import os import os
import copy import copy
from collections import namedtuple from collections import namedtuple
from mutagen.easymp4 import EasyMP4KeyError from mutagen.easymp4 import EasyMP4KeyError
from mutagen.easyid3 import EasyID3KeyError
from media.monitor.exceptions import BadSongFile from media.monitor.exceptions import BadSongFile, InvalidMetadataElement
from media.monitor.log import Loggable from media.monitor.log import Loggable
from media.monitor.pure import format_length from media.monitor.pure import format_length
import media.monitor.pure as mmp import media.monitor.pure as mmp
@ -150,17 +151,18 @@ class Metadata(Loggable):
""" """
if not os.path.exists(path): raise BadSongFile(path) if not os.path.exists(path): raise BadSongFile(path)
song_file = mutagen.File(path, easy=True) song_file = mutagen.File(path, easy=True)
ex = None exceptions = [] # for bad keys
for airtime_k, airtime_v in md.iteritems(): for airtime_k, airtime_v in md.iteritems():
if airtime_k in airtime2mutagen: if airtime_k in airtime2mutagen:
# The unicode cast here is mostly for integers that need to be # The unicode cast here is mostly for integers that need to be
# strings # strings
try: try:
song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v) song_file[ airtime2mutagen[airtime_k] ] = unicode(airtime_v)
except EasyMP4KeyError as e: except (EasyMP4KeyError, EasyID3KeyError) as e:
ex = e exceptions.append(InvalidMetadataElement(e, airtime_k,
path))
for e in exceptions: raise e
song_file.save() song_file.save()
if ex: raise ex
def __init__(self, fpath): def __init__(self, fpath):
# Forcing the unicode through # Forcing the unicode through

View File

@ -257,6 +257,8 @@ def normalized_metadata(md, original_path):
'MDATA_KEY_FILEPATH' : lambda x: os.path.normpath(x), 'MDATA_KEY_FILEPATH' : lambda x: os.path.normpath(x),
'MDATA_KEY_BPM' : lambda x: x[0:8], 'MDATA_KEY_BPM' : lambda x: x[0:8],
'MDATA_KEY_MIME' : lambda x: x.replace('audio/vorbis','audio/ogg'), 'MDATA_KEY_MIME' : lambda x: x.replace('audio/vorbis','audio/ogg'),
# Whenever 0 is reported we change it to empty
#'MDATA_KEY_BITRATE' : lambda x: '' if str(x) == '0' else x
} }
new_md = remove_whitespace(new_md) # remove whitespace fields new_md = remove_whitespace(new_md) # remove whitespace fields