mirror of https://github.com/calzoneman/sync.git
Remove file extension check (#801)
This commit is contained in:
parent
5493a81611
commit
a3a2daff4c
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.63.6",
|
"version": "3.64.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -174,11 +174,10 @@ function testUrl(url, cb, params = { redirCount: 0, cookie: '' }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^audio|^video/.test(res.headers["content-type"])) {
|
if (!/^audio|^video/.test(res.headers["content-type"])) {
|
||||||
return cb("Expected a content-type starting with 'audio' or 'video', but " +
|
cb("Could not detect a supported audio/video type. See " +
|
||||||
"got '" + res.headers["content-type"] + "'. Only direct links " +
|
"https://git.io/fjtOK for a list of supported providers. " +
|
||||||
"to video and audio files are accepted, and the website hosting " +
|
"(Content-Type was: '" + res.headers["content-type"] + "')");
|
||||||
"the file must be configured to send the correct MIME type. " +
|
return;
|
||||||
"See https://git.io/vrE75 for details.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb();
|
cb();
|
||||||
|
|
75
www/js/ui.js
75
www/js/ui.js
|
@ -269,13 +269,14 @@ $("#library_query").keydown(function(ev) {
|
||||||
|
|
||||||
$("#youtube_search").click(function () {
|
$("#youtube_search").click(function () {
|
||||||
var query = $("#library_query").val().toLowerCase();
|
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 " +
|
makeAlert("Media Link", "If you already have the link, paste it " +
|
||||||
"in the 'Media URL' box under Playlist Controls. This "+
|
"in the 'Media URL' box under Playlist Controls. This "+
|
||||||
"searchbar works like YouTube's search function.",
|
"searchbar works like YouTube's search function.",
|
||||||
"alert-danger")
|
"alert-danger")
|
||||||
.insertBefore($("#library"));
|
.insertBefore($("#library"));
|
||||||
}
|
} catch (e) {}
|
||||||
|
|
||||||
socket.emit("searchMedia", {
|
socket.emit("searchMedia", {
|
||||||
source: "yt",
|
source: "yt",
|
||||||
|
@ -368,26 +369,50 @@ function queue(pos, src) {
|
||||||
}
|
}
|
||||||
|
|
||||||
links.forEach(function (link) {
|
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 duration = undefined;
|
||||||
var title = undefined;
|
var title = undefined;
|
||||||
if (data.type === "fi") {
|
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();
|
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) {
|
if (data.id == null || data.type == null) {
|
||||||
|
@ -444,15 +469,21 @@ $("#mediaurl").keyup(function(ev) {
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
queue("end", "url");
|
queue("end", "url");
|
||||||
} else {
|
} else {
|
||||||
var url = $("#mediaurl").val().split("?")[0];
|
var editTitle = false;
|
||||||
if (url.match(/^https:\/\/(.*)?\.(flv|mp4|og[gv]|webm|mp3|mov|m4a)$/) ||
|
try {
|
||||||
url.match(/^fi:/)) {
|
if (parseMediaLink($("#mediaurl").val()).type === "fi") {
|
||||||
|
editTitle = true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editTitle) {
|
||||||
var title = $("#addfromurl-title");
|
var title = $("#addfromurl-title");
|
||||||
if (title.length === 0) {
|
if (title.length === 0) {
|
||||||
title = $("<div/>")
|
title = $("<div/>")
|
||||||
.attr("id", "addfromurl-title")
|
.attr("id", "addfromurl-title")
|
||||||
.appendTo($("#addfromurl"));
|
.appendTo($("#addfromurl"));
|
||||||
$("<span/>").text("Title (optional)")
|
$("<span/>").text("Title (optional; for raw files only)")
|
||||||
.appendTo(title);
|
.appendTo(title);
|
||||||
$("<input/>").addClass("form-control")
|
$("<input/>").addClass("form-control")
|
||||||
.attr("type", "text")
|
.attr("type", "text")
|
||||||
|
|
|
@ -1468,53 +1468,25 @@ function parseMediaLink(url) {
|
||||||
/* Raw file */
|
/* Raw file */
|
||||||
var tmp = url.split("?")[0];
|
var tmp = url.split("?")[0];
|
||||||
if (tmp.match(/^https?:\/\//)) {
|
if (tmp.match(/^https?:\/\//)) {
|
||||||
if (tmp.match(/^http:/)) {
|
if (tmp.match(/\.json$/)) {
|
||||||
Callbacks.queueFail({
|
// Custom media manifest format
|
||||||
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$/)) {
|
|
||||||
return {
|
return {
|
||||||
id: url,
|
id: url,
|
||||||
type: "cm"
|
type: "cm"
|
||||||
};
|
};
|
||||||
} else if (tmp.match(/kissanime|kimcartoon|kisscartoon/i)) {
|
} else {
|
||||||
Callbacks.queueFail({
|
// Assume raw file (server will check)
|
||||||
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)$/)) {
|
|
||||||
return {
|
return {
|
||||||
id: url,
|
id: url,
|
||||||
type: "fi"
|
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 {
|
throw new Error(
|
||||||
id: null,
|
'Could not determine video type. Check https://git.io/fjtOK for a list ' +
|
||||||
type: null
|
'of supported media providers.'
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendVideoUpdate() {
|
function sendVideoUpdate() {
|
||||||
|
|
Loading…
Reference in New Issue