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

This commit is contained in:
martin 2011-10-03 23:13:44 -04:00
commit ed8cdc7db3
28 changed files with 176 additions and 42 deletions

View File

@ -13,6 +13,7 @@ require_once 'DB.php';
require_once 'Preference.php';
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
require_once 'soundcloud-api/Services/Soundcloud.php';
global $CC_CONFIG, $CC_DBC;
$dsn = $CC_CONFIG['dsn'];

View File

@ -37,6 +37,6 @@ define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
// Soundcloud contants
define('SOUNDCLOUD_NULL', -1);
define('SOUNDCLOUD_NOT_UPLOADED_YET', -1);
define('SOUNDCLOUD_PROGRESS', -2);
define('SOUNDCLOUD_ERROR', -3);

View File

@ -400,7 +400,7 @@ class ApiController extends Zend_Controller_Action
$tags = array_merge($hosts, array($show_name));
try {
$soundcloud = new Application_Model_AtSoundcloud();
$soundcloud = new Application_Model_Soundcloud();
$soundcloud_id = $soundcloud->uploadTrack($file->getFilePath(), $tmpTitle, $description, $tags, $show_start_time, $show_genre);
$file->setSoundCloudFileId($soundcloud_id);
break;

View File

@ -91,7 +91,7 @@ class LibraryController extends Zend_Controller_Action
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => 'Download');
if (Application_Model_Preference::GetDoSoundCloudUpload()) {
if (Application_Model_Preference::GetUploadToSoundcloudOption()) {
$text = "Upload to Soundcloud";
if(!is_null($file->getSoundCloudId())){
$text = "Re-upload to Soundcloud";
@ -213,7 +213,10 @@ class LibraryController extends Zend_Controller_Action
$file->setDbColMetadata($formdata);
$data = $file->getMetadata();
// set MDATA_KEY_FILEPATH
$data['MDATA_KEY_FILEPATH'] = $file->getFilePath();
Logging::log($data['MDATA_KEY_FILEPATH']);
Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data);
$this->_helper->redirector('index');

View File

@ -37,6 +37,8 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]);
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]);
Application_Model_Preference::SetSoundCloudDownloadbleOption($values["preferences_soundcloud"]["SoundCloudDownloadbleOption"]);
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
Application_Model_Preference::SetSoundCloudPassword($values["preferences_soundcloud"]["SoundCloudPassword"]);
Application_Model_Preference::SetSoundCloudTags($values["preferences_soundcloud"]["SoundCloudTags"]);

View File

@ -47,6 +47,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/full-calendar-functions.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/add-show.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/schedule/schedule.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery-ui-timepicker.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/fullcalendar.css');
@ -175,7 +176,7 @@ class ScheduleController extends Zend_Controller_Action
if ($showEndDateHelper->getTimestamp() <= $epochNow
&& $show->isRecorded()
&& Application_Model_Preference::GetDoSoundCloudUpload()) {
&& Application_Model_Preference::GetUploadToSoundcloudOption()) {
if(is_null($show->getSoundCloudFileId())){
$menu[] = array('action' => array('type' => 'fn',
'callback' => "window['uploadToSoundCloud']($id)"),

View File

@ -20,6 +20,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'ViewHelper',
'Description',
array('Label', array('tag' =>'dt'))));
$startDate->setAttrib('alt', 'date');
$this->addElement($startDate);
// Add start time element
@ -36,6 +37,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'ViewHelper',
'Errors',
array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
$startTime->setAttrib('alt', 'time');
$this->addElement($startTime);
// Add end date element
@ -53,6 +55,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'ViewHelper',
'Description',
array('Label', array('tag' =>'dt'))));
$endDate->setAttrib('alt', 'date');
$this->addElement($endDate);
// Add end time element
@ -69,6 +72,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
'ViewHelper',
'Errors',
array(array('close'=>'HtmlTag'), array('tag' => 'dd', 'closeOnly'=>true))));
$endTime->setAttrib('alt', 'time');
$this->addElement($endTime);
// Add duration element

View File

@ -11,13 +11,33 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
//enable soundcloud uploads
$this->addElement('checkbox', 'UseSoundCloud', array(
'label' => 'Upload Recorded Shows To SoundCloud',
'label' => 'Automatically Upload Recorded Shows',
'required' => false,
'value' => Application_Model_Preference::GetDoSoundCloudUpload(),
'decorators' => array(
'ViewHelper'
)
));
));
//enable soundcloud uploads option
$this->addElement('checkbox', 'UploadToSoundcloudOption', array(
'label' => 'Enable Soundcloud Upload',
'required' => false,
'value' => Application_Model_Preference::GetUploadToSoundcloudOption(),
'decorators' => array(
'ViewHelper'
)
));
//enable downloadable for soundcloud
$this->addElement('checkbox', 'SoundCloudDownloadbleOption', array(
'label' => 'Automatically Mark Files "Downloadable" on SoundCloud',
'required' => false,
'value' => Application_Model_Preference::GetSoundCloudDownloadbleOption(),
'decorators' => array(
'ViewHelper'
)
));
//SoundCloud Username
$this->addElement('text', 'SoundCloudUser', array(

View File

@ -20,7 +20,7 @@
<div class="wrapper">
<!--Set to z-index 254 to make it lower than the top-panel and the ZFDebug info bar, but higher than the side-playlist-->
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow omega-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded" style="z-index:254"><?php echo $this->layout()->library ?></div>
<div id="side_playlist" class="ui-widget ui-widget-content block-shadow omega-block"><?php echo $this->layout()->spl ?></div>
</div>
</body>

View File

@ -432,11 +432,30 @@ class Application_Model_Preference
}
public static function GetEnableStreamConf(){
if(self::GetValue("enable_stream_conf") == Null){
return "true";
}
return self::GetValue("enable_stream_conf");
}
public static function GetAirtimeVersion(){
return self::GetValue("system_version");
}
public static function SetUploadToSoundcloudOption($upload) {
self::SetValue("soundcloud_upload_option", $upload);
}
public static function GetUploadToSoundcloudOption() {
return self::GetValue("soundcloud_upload_option");
}
public static function SetSoundCloudDownloadbleOption($upload) {
self::SetValue("soundcloud_downloadable", $upload);
}
public static function GetSoundCloudDownloadbleOption() {
return self::GetValue("soundcloud_downloadable");
}
}

View File

@ -1,8 +1,6 @@
<?php
require_once 'soundcloud-api/Services/Soundcloud.php';
class Application_Model_AtSoundcloud {
class Application_Model_Soundcloud {
private $_soundcloud;
@ -40,13 +38,15 @@ class Application_Model_AtSoundcloud {
$tags = Application_Model_Preference::GetSoundCloudTags();
}
$downloadable = Application_Model_Preference::GetSoundCloudDownloadbleOption() == '1'?true:false;
$track_data = array(
'track[sharing]' => 'private',
'track[title]' => $filename,
'track[asset_data]' => '@' . $filepath,
'track[tag_list]' => $tags,
'track[description]' => $description,
'track[downloadable]' => true,
'track[downloadable]' => $downloadable,
);

View File

@ -931,21 +931,20 @@ class Application_Model_StoredFile {
public function uploadToSoundCloud()
{
global $CC_CONFIG;
$file = $this->_file;
if(is_null($file)) {
return "File does not exist";
}
if(Application_Model_Preference::GetDoSoundCloudUpload())
if(Application_Model_Preference::GetUploadToSoundcloudOption())
{
for($i=0; $i<$CC_CONFIG['soundcloud-connection-retries']; $i++) {
$description = $file->getDbTrackTitle();
$tag = "";
$genre = $file->getDbGenre();
$release = $file->getDbYear();
try {
$soundcloud = new Application_Model_AtSoundcloud();
$soundcloud = new Application_Model_Soundcloud();
$soundcloud_id = $soundcloud->uploadTrack($this->getFilePath(), $this->getName(), $description, $tag, $release, $genre);
$this->setSoundCloudFileId($soundcloud_id);
break;

View File

@ -1,6 +1,19 @@
<fieldset class="padded">
<dl class="zend_form">
<dd id="UseSoundCloud-element" class="block-display" style=" margin:6px 0 10px 0">
<dd id="UploadToSoundcloudOption-element" class="block-display" style=" margin:6px 0 10px 0">
<label class="optional" for="UploadToSoundcloudOption">
<?php echo $this->element->getElement('UploadToSoundcloudOption') ?>
<strong><?php echo $this->element->getElement('UploadToSoundcloudOption')->getLabel() ?></strong>
</label>
<?php if($this->element->getElement('UploadToSoundcloudOption')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('UploadToSoundcloudOption')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dd id="UseSoundCloud-element" class="block-display" style="padding-left:20px; margin:6px 0 10px 0">
<label class="optional" for="UseSoundCloud">
<?php echo $this->element->getElement('UseSoundCloud') ?>
<strong><?php echo $this->element->getElement('UseSoundCloud')->getLabel() ?></strong>
@ -13,6 +26,19 @@
</ul>
<?php endif; ?>
</dd>
<dd id="SoundCloudDownloadbleOption-element" class="block-display" style="padding-left:20px; margin:6px 0 10px 0">
<label class="optional" for="SoundCloudDownloadbleOption">
<?php echo $this->element->getElement('SoundCloudDownloadbleOption') ?>
<strong><?php echo $this->element->getElement('SoundCloudDownloadbleOption')->getLabel() ?></strong>
</label>
<?php if($this->element->getElement('SoundCloudDownloadbleOption')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('SoundCloudDownloadbleOption')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="SoundCloudUser-label" class="block-display">
<label class="optional" for="SoundCloudUser"><?php echo $this->element->getElement('SoundCloudUser')->getLabel() ?></label>
</dt>

View File

@ -2,7 +2,7 @@
$s_name = "s".$this->stream_number;
?>
<h3 class="collapsible-header"><span class="arrow-icon"></span>Stream <?php echo $this->stream_number?></h3>
<div class="stream-setting-content" id="<?=$s_name?>-config">
<div class="stream-setting-content" <?php echo $this->stream_number != '1'?'style="display: none;':''?> id="<?=$s_name?>-config">
<fieldset class="padded">
<dl class="zend_form clearfix">
<dt id="<?=$s_name?>Enabled-label">
@ -64,10 +64,10 @@
Additional Options
</legend>
<dl class="zend_form">
<dt id="outputUser-label" class="block-display">
<dt id="outputUser-label">
<label for="outputUser"><?php echo $this->element->getElement('user')->getLabel()?> :</label>
</dt>
<dd id="outputUser-element" class="block-display">
<dd id="outputUser-element">
<?php echo $this->element->getElement('user')?>
<?php if($this->element->getElement('user')->hasErrors()) : ?>
<ul class='errors'>
@ -77,10 +77,10 @@
</ul>
<?php endif; ?>
</dd>
<dt id="outputPassword-label" class="block-display">
<dt id="outputPassword-label">
<label class="optional" for="outputPassword"><?php echo $this->element->getElement('pass')->getLabel()?> :</label>
</dt>
<dd id="outputPassword-element" class="block-display clearfix">
<dd id="outputPassword-element" class="clearfix">
<?php echo $this->element->getElement('pass')?>
<?php if($this->element->getElement('pass')->hasErrors()) : ?>
<ul class='errors'>
@ -93,10 +93,10 @@
<dt class="block-display info-block">
The following info will be displayed to listeners in their media player:
</dt>
<dt id="stationDescription-label" class="block-display">
<dt id="stationDescription-label">
<label for="stationDescription"><?php echo $this->element->getElement('description')->getLabel()?> :</label>
</dt>
<dd id="stationDescription-element" class="block-display clearfix">
<dd id="stationDescription-element" class="clearfix">
<?php echo $this->element->getElement('description')?>
<?php if($this->element->getElement('description')->hasErrors()) : ?>
<ul class='errors'>
@ -106,10 +106,10 @@
</ul>
<?php endif; ?>
</dd>
<dt id="stationURL-label" class="block-display">
<dt id="stationURL-label">
<label for="stationURL"><?php echo $this->element->getElement('url')->getLabel()?> :</label>
</dt>
<dd id="stationURL-element" class="block-display clearfix">
<dd id="stationURL-element" class="clearfix">
<?php echo $this->element->getElement('url')?>
<span class="info-text-small">(Your radio station website)</span>
<?php if($this->element->getElement('url')->hasErrors()) : ?>
@ -120,10 +120,10 @@
</ul>
<?php endif; ?>
</dd>
<dt id="outputGenre-label" class="block-display">
<dt id="outputGenre-label">
<label for="outputGenre"><?php echo $this->element->getElement('genre')->getLabel()?> :</label>
</dt>
<dd id="outputGenre-element" class="block-display">
<dd id="outputGenre-element">
<?php echo $this->element->getElement('genre')?>
<?php if($this->element->getElement('genre')->hasErrors()) : ?>
<ul class='errors'>
@ -133,10 +133,10 @@
</ul>
<?php endif; ?>
</dd>
<dt id="outputMountpoint-label" class="block-display">
<dt id="outputMountpoint-label">
<label for="outputMountpoint"><?php echo $this->element->getElement('mount')->getLabel()?> :</label>
</dt>
<dd id="outputMountpoint-element" class="block-display">
<dd id="outputMountpoint-element">
<?php echo $this->element->getElement('mount')?>
<?php if($this->element->getElement('mount')->hasErrors()) : ?>
<ul class='errors'>
@ -148,11 +148,11 @@
</dd>
</dl>
</fieldset>
<dt id="outputStreamURL-label" class="block-display">
<dt id="outputStreamURL-label">
<label for="outputStreamURL">Stream URL: </label>
</dt>
<dd id="outputStreamURL-element" class="block-display">
<p id="stream_url"></p>
<dd id="outputStreamURL-element">
<span id="stream_url"></span>
</dd>
</dl>
</fieldset>

View File

@ -1,3 +1,8 @@
<style type="text/css">
#plupload_files input[type="file"] {
font-size: 200px !important;
}
</style>
<form id="plupload_form">
<div id="plupload_files"></div>
</form>

View File

@ -1,5 +1,5 @@
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong stream-config">
<h2 style="float:left">Stream Settings</h2>
<h2 <?php if($this->enable_stream_conf == "true"){?>style="float:left"<?php }?>>Stream Settings</h2>
<?php if($this->enable_stream_conf == "true"){?>
<form method="post" action="/Preference/stream-setting" enctype="application/x-www-form-urlencoded">
<div class="button-bar bottom" id="submit-element" style="float:right">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1566,6 +1566,10 @@ div.success{
background:url(images/icon_soundcloud.png) no-repeat 0 0;
width:21px;
}
.small-icon.sc-error {
background:url(images/icon_soundcloud_error2.png) no-repeat 0 0;
width:21px;
}
.small-icon.progress {
background:url(images/upload-icon.gif) no-repeat;
background-color:black;

View File

@ -154,8 +154,12 @@ function dtDrawCallback() {
}
function addProgressIcon(id) {
$("#au_"+id).find("td:eq(0)").append('<span id="'+id+'" class="small-icon progress"></span>')
$("span[id="+id+"]").addClass("progress");
if($("#au_"+id).find("td:eq(0)").find("span").length > 0){
$("#au_"+id).find("td:eq(0)").find("span").removeClass();
$("span[id="+id+"]").addClass("small-icon progress");
}else{
$("#au_"+id).find("td:eq(0)").append('<span id="'+id+'" class="small-icon progress"></span>')
}
}
function checkSCUploadStatus(){

View File

@ -69,6 +69,7 @@ function setWatchedDirEvents() {
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>Manage Media Folders</h2>");
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});
@ -86,6 +87,7 @@ function setWatchedDirEvents() {
function(json) {
$("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>Manage Media Folders</h2>");
$("#watched-folder-section").append(json.subform);
setWatchedDirEvents();
});

View File

@ -120,6 +120,12 @@ $(document).ready(function() {
return false;
});
$('.collapsible-header').click(function() {
$(this).next().toggle('fast');
$(this).toggleClass("close");
return false;
})
showErrorSections()

View File

@ -419,10 +419,16 @@ function showErrorSections() {
$("#schedule-record-rebroadcast").show();
$("#add_show_rebroadcast_relative").show();
}
$('input:text').setMask()
}
$(document).ready(function() {
$.mask.masks = $.extend($.mask.masks,{
date:{ mask: '9999-19-39'},
time:{ mask: '29:69'}
})
$('input:text').setMask()
//setAddShowEvents();
});
@ -438,6 +444,13 @@ $(window).resize(function(){
});
$(window).load(function() {
$.mask.masks = $.extend($.mask.masks,{
date:{ mask: '9999-19-39'},
time:{ mask: '29:69'}
})
$('input:text').setMask()
setAddShowEvents();
});

File diff suppressed because one or more lines are too long

View File

@ -462,4 +462,11 @@ class AirtimeInstall
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
fclose($fp);
}
public static function removeVirtualEnvDistributeFile(){
echo "* Removing distribute-0.6.10.tar.gz".PHP_EOL;
if(file_exists('/usr/share/python-virtualenv/distribute-0.6.10.tar.gz')){
exec("rm -f /usr/share/python-virtualenv/distribute-0.6.10.tar.gz");
}
}
}

View File

@ -80,6 +80,7 @@ if ($results == 0) {
AirtimeInstall::RemoveSymlinks();
AirtimeInstall::UninstallBinaries();
AirtimeInstall::RemoveLogDirectories();
AirtimeInstall::removeVirtualEnvDistributeFile();
AirtimeIni::RemoveMonitFile();
@unlink('/etc/cron.d/airtime-crons');

View File

@ -422,12 +422,12 @@ class AirTimeApiClient(ApiClientInterface):
elapsed = (time.time() - start)
logger.info("time taken to get response %s", elapsed)
if(is_record):
if("error" not in response and is_record):
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_recorded"])
url = url.replace("%%fileid%%", str(response[u'id']))
url = url.replace("%%showinstanceid%%", str(md['MDATA_KEY_TRACKNUMBER']))
logger.debug(url)
url = url.replace("%%api_key%%", self.config["api_key"])
logger.debug(url)
req = urllib2.Request(url)
response = urllib2.urlopen(req).read()

View File

@ -125,7 +125,7 @@ class AirtimeMetadata:
self.logger.debug("Saving %s to file", key)
self.logger.debug(value)
if isinstance(value, basestring) and (len(value) > 0):
airtime_file[self.airtime2mutagen[key]] = unicode(value, "utf-8")
airtime_file[self.airtime2mutagen[key]] = api_client.encode_to(value, 'utf-8')
elif isinstance(value, int):
airtime_file[self.airtime2mutagen[key]] = str(value)

View File

@ -36,6 +36,7 @@ class AirtimeProcessEvent(ProcessEvent):
self.md_manager = AirtimeMetadata()
self.mmc = mmc
self.api_client = api_client
self.create_dict = {}
def add_filepath_to_ignore(self, filepath):
self.ignore_event.add(filepath)
@ -87,6 +88,14 @@ class AirtimeProcessEvent(ProcessEvent):
else:
self.logger.info("Removing the watch folder failed: %s", res['msg']['error'])
def process_IN_CREATE(self, event):
self.logger.info("event: %s", event)
if not event.dir:
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True})
self.create_dict[event.pathname] = time.time()
#event.dir: True if the event was raised against a directory.
#event.name: filename
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
@ -94,7 +103,10 @@ class AirtimeProcessEvent(ProcessEvent):
# copy was done. Hence, IN_CLOSE_WRITE is the correct one to handle.
def process_IN_CLOSE_WRITE(self, event):
self.logger.info("event: %s", event)
self.handle_created_file(event.dir, event.pathname, event.name)
self.logger.info("create_dict: %s", self.create_dict)
if event.pathname in self.create_dict:
self.create_dict.pop(event.pathname)
self.handle_created_file(event.dir, event.pathname, event.name)
def handle_created_file(self, dir, pathname, name):
if not dir:
@ -255,6 +267,10 @@ class AirtimeProcessEvent(ProcessEvent):
del self.cookies_IN_MOVED_FROM[k]
self.handle_removed_file(False, event.pathname)
for k, t in self.create_dict.items():
now = time.time()
if now - t > 5:
del self.create_dict[k]
#check for any events received from Airtime.
try: