This commit is contained in:
calzoneman 2013-07-04 19:11:13 -04:00
parent a2036e4383
commit ec035bd93f
5 changed files with 50 additions and 0 deletions

View File

@ -59,6 +59,7 @@ var Channel = function(name) {
playlistjump: 1.5,
playlistaddlist: 1.5,
playlistaddlive: 1.5,
exceedmaxlength: 2,
addnontemp: 2,
settemp: 2,
playlistgeturl: 1.5,
@ -78,6 +79,7 @@ var Channel = function(name) {
allow_voteskip: true,
voteskip_ratio: 0.5,
pagetitle: this.name,
maxlength: 0,
externalcss: "",
externaljs: "",
chat_antiflood: false,
@ -1194,9 +1196,15 @@ Channel.prototype.tryQueue = function(user, data) {
Channel.prototype.addMedia = function(data, user) {
data.temp = isLive(data.type) || !this.hasPermission(user, "addnontemp");
data.queueby = user ? user.name : "";
data.maxlength = this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength;
var chan = this;
if(data.id in this.library) {
var m = this.library[data.id].dup();
if(data.maxlength && m.seconds > data.maxlength) {
user.socket.emit("queueFail", "Media is too long!");
return;
}
data.media = m;
this.playlist.addCachedMedia(data, function (err, item) {
if(err) {

View File

@ -216,6 +216,12 @@ Playlist.prototype.addMedia = function(data, callback) {
return;
}
if(data.maxlength && media.seconds > data.maxlength) {
action.expire = 0;
callback("Media is too long!", null);
return;
}
it.media = media;
it.temp = data.temp;
it.queueby = data.queueby;

View File

@ -49,9 +49,21 @@
genPermissionsEditor();
$("#chanopts_submit").click(function() {
var hms = $("#opt_maxlength").val().split(":");
var len = 0;
if(hms.length == 3) {
len = parseInt(hms[0]) * 3600 + parseInt(hms[1]) * 60 + parseInt(hms[2]);
}
else if(hms.length == 2) {
len = parseInt(hms[0]) * 60 + parseInt(hms[1]);
}
else {
len = parseInt(hms[0]);
}
socket.emit("setOptions", {
allow_voteskip: $("#opt_allow_voteskip").prop("checked"),
voteskip_ratio: parseFloat($("#opt_voteskip_ratio").val()),
maxlength: len,
pagetitle: $("#opt_pagetitle").val() || CHANNEL.name,
externalcss: $("#opt_externalcss").val(),
externaljs: $("#opt_externaljs").val(),

View File

@ -800,6 +800,22 @@ function handleModPermissions() {
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
(function() {
if(typeof CHANNEL.opts.maxlength != "number") {
$("#opt_maxlength").val("");
return;
}
var h = parseInt(CHANNEL.opts.maxlength / 3600);
h = ""+h;
if(h.length < 2) h = "0" + h;
var m = parseInt((CHANNEL.opts.maxlength % 3600) / 60);
m = ""+m;
if(m.length < 2) m = "0" + m;
var s = parseInt(CHANNEL.opts.maxlength % 60);
s = ""+s;
if(s.length < 2) s = "0" + s;
$("#opt_maxlength").val(h + ":" + m + ":" + s);
})();
$("#csstext").val(CHANNEL.css);
$("#jstext").val(CHANNEL.js);
$("#motdtext").val(CHANNEL.motd_text);
@ -1388,6 +1404,7 @@ function genPermissionsEditor() {
makeOption("Jump to video", "playlistjump", standard, CHANNEL.perms.playlistjump+"");
makeOption("Queue playlist", "playlistaddlist", standard, CHANNEL.perms.playlistaddlist+"");
makeOption("Queue livestream", "playlistaddlive", standard, CHANNEL.perms.playlistaddlive+"");
makeOption("Exceed maximum media length", "exceedmaxlength", standard, CHANNEL.perms.exceedmaxlength+"");
makeOption("Add nontemporary media", "addnontemp", standard, CHANNEL.perms.addnontemp+"");
makeOption("Temp/untemp playlist item", "settemp", standard, CHANNEL.perms.settemp+"");
makeOption("Shuffle playlist", "playlistshuffle", standard, CHANNEL.perms.playlistshuffle+"");

View File

@ -49,6 +49,13 @@
<input type="text" id="opt_voteskip_ratio" placeholder="0.5">
</div>
</div>
<!-- max video length -->
<div class="control-group">
<label class="control-label" for="opt_maxlength">Maximum Video Length</label>
<div class="controls">
<input type="text" id="opt_maxlength" placeholder="HH:MM:SS">
</div>
</div>
<hr>
<strong>Admin-Only Controls</strong>
<!-- page title -->