Remove file extension check (#801)

This commit is contained in:
Calvin Montgomery 2019-04-07 16:32:58 -07:00
parent 5493a81611
commit a3a2daff4c
4 changed files with 66 additions and 64 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.63.6",
"version": "3.64.0",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -174,11 +174,10 @@ function testUrl(url, cb, params = { redirCount: 0, cookie: '' }) {
}
if (!/^audio|^video/.test(res.headers["content-type"])) {
return cb("Expected a content-type starting with 'audio' or 'video', but " +
"got '" + res.headers["content-type"] + "'. Only direct links " +
"to video and audio files are accepted, and the website hosting " +
"the file must be configured to send the correct MIME type. " +
"See https://git.io/vrE75 for details.");
cb("Could not detect a supported audio/video type. See " +
"https://git.io/fjtOK for a list of supported providers. " +
"(Content-Type was: '" + res.headers["content-type"] + "')");
return;
}
cb();

View File

@ -269,13 +269,14 @@ $("#library_query").keydown(function(ev) {
$("#youtube_search").click(function () {
var query = $("#library_query").val().toLowerCase();
if(parseMediaLink(query).type !== null) {
try {
parseMediaLink(query);
makeAlert("Media Link", "If you already have the link, paste it " +
"in the 'Media URL' box under Playlist Controls. This "+
"searchbar works like YouTube's search function.",
"alert-danger")
.insertBefore($("#library"));
}
} catch (e) {}
socket.emit("searchMedia", {
source: "yt",
@ -368,26 +369,50 @@ function queue(pos, src) {
}
links.forEach(function (link) {
var data = parseMediaLink(link);
var data;
try {
data = parseMediaLink(link);
} catch (error) {
Callbacks.queueFail({
link: link,
msg: error.message
});
return;
}
var duration = undefined;
var title = undefined;
if (data.type === "fi") {
if (data.id.match(/^http:/)) {
Callbacks.queueFail({
link: data.id,
msg: "Raw files must begin with 'https'. Plain http is not supported."
});
return;
}
// Explicit checks for kissanime and mega.nz since everyone
// asks about them
if (data.id.match(/kissanime|kimcartoon|kisscartoon/i)) {
Callbacks.queueFail({
link: data.id,
msg: "Kisscartoon and Kissanime are not supported. See https://git.io/vxS9n" +
" for more information about why these cannot be supported."
});
return;
} else if (data.id.match(/mega\.nz/)) {
Callbacks.queueFail({
link: data.id,
msg: "Mega.nz is not supported. See https://git.io/fx6fz" +
" for more information about why mega.nz cannot be supported."
});
return;
}
// Raw files allow title overrides since the ffprobe tag data
// is not always correct.
title = $("#addfromurl-title-val").val();
} else if (data.type === "vm") {
/*
* As of December 2017, vid.me is no longer in service.
* Leaving this temporarily to hopefully avoid confusion
* for people pasting old vid.me links.
*
* TODO: remove at some point in the future
*/
Callbacks.queueFail({
link: link,
msg: "As of December 2017, vid.me is no longer in service."
});
return;
}
if (data.id == null || data.type == null) {
@ -444,15 +469,21 @@ $("#mediaurl").keyup(function(ev) {
if (ev.keyCode === 13) {
queue("end", "url");
} else {
var url = $("#mediaurl").val().split("?")[0];
if (url.match(/^https:\/\/(.*)?\.(flv|mp4|og[gv]|webm|mp3|mov|m4a)$/) ||
url.match(/^fi:/)) {
var editTitle = false;
try {
if (parseMediaLink($("#mediaurl").val()).type === "fi") {
editTitle = true;
}
} catch (error) {
}
if (editTitle) {
var title = $("#addfromurl-title");
if (title.length === 0) {
title = $("<div/>")
.attr("id", "addfromurl-title")
.appendTo($("#addfromurl"));
$("<span/>").text("Title (optional)")
$("<span/>").text("Title (optional; for raw files only)")
.appendTo(title);
$("<input/>").addClass("form-control")
.attr("type", "text")

View File

@ -1468,53 +1468,25 @@ function parseMediaLink(url) {
/* Raw file */
var tmp = url.split("?")[0];
if (tmp.match(/^https?:\/\//)) {
if (tmp.match(/^http:/)) {
Callbacks.queueFail({
link: url,
msg: "Raw files must begin with 'https'. Plain http is not supported."
});
throw new Error("ERROR_QUEUE_HTTP");
} else if (tmp.match(/\.json$/)) {
if (tmp.match(/\.json$/)) {
// Custom media manifest format
return {
id: url,
type: "cm"
};
} else if (tmp.match(/kissanime|kimcartoon|kisscartoon/i)) {
Callbacks.queueFail({
link: url,
msg: "Kisscartoon and Kissanime are not supported. See https://git.io/vxS9n" +
" for more information about why these cannot be supported."
});
throw new Error("ERROR_QUEUE_KISS");
} else if (tmp.match(/mega\.nz/)) {
Callbacks.queueFail({
link: url,
msg: "Mega.nz is not supported. See https://git.io/fx6fz" +
" for more information about why mega.nz cannot be supported."
});
throw new Error("ERROR_QUEUE_MEGA");
} else if (tmp.match(/\.(mp4|flv|webm|og[gv]|mp3|mov|m4a)$/)) {
} else {
// Assume raw file (server will check)
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, ogv, mp3, mov, m4a. " +
"For more information about why other filetypes are not supported, " +
"see https://git.io/va9g9"
});
// Lol I forgot about this hack
throw new Error("ERROR_QUEUE_UNSUPPORTED_EXTENSION");
}
}
return {
id: null,
type: null
};
throw new Error(
'Could not determine video type. Check https://git.io/fjtOK for a list ' +
'of supported media providers.'
);
}
function sendVideoUpdate() {