Implement raw file queues

This commit is contained in:
Calvin Montgomery 2014-06-03 21:21:00 -07:00
parent ac7f0ac47a
commit 1d1630fb50
11 changed files with 140 additions and 31 deletions

View file

@ -340,12 +340,16 @@ function queue(pos, src) {
var link = $("#mediaurl").val();
var data = parseMediaLink(link);
var duration = undefined;
var title = undefined;
if (link.indexOf("jw:") === 0) {
duration = parseInt($("#addfromurl-duration-val").val());
if (duration <= 0 || isNaN(duration)) {
duration = undefined;
}
}
if (data.type === "fi") {
title = $("#addfromurl-title-val").val();
}
if (data.id == null || data.type == null) {
makeAlert("Error", "Failed to parse link. Please check that it is correct",
@ -354,11 +358,13 @@ function queue(pos, src) {
} else {
$("#mediaurl").val("");
$("#addfromurl-duration").remove();
$("#addfromurl-title").remove();
socket.emit("queue", {
id: data.id,
type: data.type,
pos: pos,
duration: duration,
title: title,
temp: $(".add-temp").prop("checked")
});
}
@ -373,21 +379,46 @@ $("#ce_queue_end").click(queue.bind(this, "end", "customembed"));
$("#mediaurl").keyup(function(ev) {
if (ev.keyCode === 13) {
queue("end", "url");
} else if ($("#mediaurl").val().indexOf("jw:") === 0) {
var duration = $("#addfromurl-duration");
if (duration.length === 0) {
duration = $("<div/>")
.attr("id", "addfromurl-duration")
.appendTo($("#addfromurl"));
$("<span/>").text("JWPlayer Duration (seconds) (optional)")
.appendTo(duration);
$("<input/>").addClass("form-control")
.attr("type", "text")
.attr("id", "addfromurl-duration-val")
.appendTo($("#addfromurl-duration"));
}
} else {
$("#addfromurl-duration").remove();
if ($("#mediaurl").val().indexOf("jw:") === 0) {
var duration = $("#addfromurl-duration");
if (duration.length === 0) {
duration = $("<div/>")
.attr("id", "addfromurl-duration")
.appendTo($("#addfromurl"));
$("<span/>").text("JWPlayer Duration (seconds) (optional)")
.appendTo(duration);
$("<input/>").addClass("form-control")
.attr("type", "text")
.attr("id", "addfromurl-duration-val")
.appendTo($("#addfromurl-duration"));
}
} else {
$("#addfromurl-duration").remove();
}
var url = $("#mediaurl").val().split("?")[0];
if (url.match(/^https?:\/\/(.*)?\.(flv|mp4|ogg|webm)$/)) {
var title = $("#addfromurl-title");
if (title.length === 0) {
title = $("<div/>")
.attr("id", "addfromurl-title")
.appendTo($("#addfromurl"));
$("<span/>").text("Title (optional)")
.appendTo(title);
$("<input/>").addClass("form-control")
.attr("type", "text")
.attr("id", "addfromurl-title-val")
.keyup(function (ev) {
if (ev.keyCode === 13) {
queue("end", "url");
}
})
.appendTo($("#addfromurl-title"));
}
} else {
$("#addfromurl-title").remove();
}
}
});

View file

@ -58,6 +58,8 @@ function formatURL(data) {
return "http://ustream.tv/" + data.id;
case "gd":
return "https://docs.google.com/file/d/" + data.id;
case "fi":
return data.id;
default:
return "#";
}
@ -1284,6 +1286,24 @@ function parseMediaLink(url) {
};
}
/* Raw file */
var tmp = url.split("?")[0];
if (tmp.match(/^https?:\/\//)) {
if (tmp.match(/\.(mp4|flv|webm|ogg)$/)) {
return {
id: url,
type: "fi"
};
} else {
Callbacks.queueFail({
link: url,
msg: "The file you are attempting to queue does not match the supported " +
"file extensions mp4, flv, webm, ogg."
});
throw new Error("ERROR_QUEUE_UNSUPPORTED_EXTENSION");
}
}
return {
id: null,
type: null
@ -1728,6 +1748,7 @@ function genPermissionsEditor() {
makeOption("Queue playlist", "playlistaddlist", standard, CHANNEL.perms.playlistaddlist+"");
makeOption("Queue livestream", "playlistaddlive", standard, CHANNEL.perms.playlistaddlive+"");
makeOption("Embed custom media", "playlistaddcustom", standard, CHANNEL.perms.playlistaddcustom + "");
makeOption("Add raw video file", "playlistaddrawfile", standard, CHANNEL.perms.playlistaddrawfile + "");
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+"");