mirror of https://github.com/calzoneman/sync.git
Bugfixes
- Better YouTube URL parsing - Check for invalid regexes and report them - Channel names are no longer case-sensitive
This commit is contained in:
parent
52fe508628
commit
7def0b174f
12
channel.js
12
channel.js
|
@ -128,6 +128,11 @@ Channel.prototype.loadMysql = function() {
|
||||||
Logger.syslog.log("Channel " + this.name + " is unregistered.");
|
Logger.syslog.log("Channel " + this.name + " is unregistered.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// [](/picard) I didn't realize that MySQL wasn't case sensitive.
|
||||||
|
// My bad.
|
||||||
|
else if(rows[0].name != this.name) {
|
||||||
|
this.name = rows[0].name;
|
||||||
|
}
|
||||||
this.registered = true;
|
this.registered = true;
|
||||||
|
|
||||||
// Load library
|
// Load library
|
||||||
|
@ -674,12 +679,13 @@ Channel.prototype.unqueue = function(data) {
|
||||||
pos: data.pos
|
pos: data.pos
|
||||||
});
|
});
|
||||||
|
|
||||||
if(data.pos < this.currentPosition) {
|
|
||||||
this.currentPosition--;
|
|
||||||
}
|
|
||||||
if(data.pos == this.currentPosition) {
|
if(data.pos == this.currentPosition) {
|
||||||
this.currentPosition--;
|
this.currentPosition--;
|
||||||
this.playNext();
|
this.playNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(data.pos < this.currentPosition) {
|
||||||
|
this.currentPosition--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
user.js
5
user.js
|
@ -252,7 +252,12 @@ User.prototype.initCallbacks = function() {
|
||||||
this.socket.on("chatFilter", function(data) {
|
this.socket.on("chatFilter", function(data) {
|
||||||
if(Rank.hasPermission(this, "chatFilter")) {
|
if(Rank.hasPermission(this, "chatFilter")) {
|
||||||
if(data.cmd && data.cmd == "update" && this.channel != null) {
|
if(data.cmd && data.cmd == "update" && this.channel != null) {
|
||||||
|
try {
|
||||||
data.filter[0] = new RegExp(data.filter[0], "g");
|
data.filter[0] = new RegExp(data.filter[0], "g");
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.channel.updateFilter(data.filter);
|
this.channel.updateFilter(data.filter);
|
||||||
}
|
}
|
||||||
else if(data.cmd && data.cmd == "remove" && this.channel != null) {
|
else if(data.cmd && data.cmd == "remove" && this.channel != null) {
|
||||||
|
|
|
@ -484,6 +484,7 @@ function removeCurrentPlayer(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVideoURL(url){
|
function parseVideoURL(url){
|
||||||
|
url = url.trim()
|
||||||
if(typeof(url) != "string")
|
if(typeof(url) != "string")
|
||||||
return null;
|
return null;
|
||||||
if(url.indexOf("youtu.be") != -1 || url.indexOf("youtube.com") != -1) {
|
if(url.indexOf("youtu.be") != -1 || url.indexOf("youtube.com") != -1) {
|
||||||
|
@ -505,21 +506,18 @@ function parseVideoURL(url){
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseYTURL(url) {
|
function parseYTURL(url) {
|
||||||
url = url.replace("feature=player_embedded&", "");
|
var m = url.match(/v=([^&#]+)/);
|
||||||
if(url.indexOf("&list=") != -1)
|
|
||||||
url = url.substring(0, url.indexOf("&list="));
|
|
||||||
var m = url.match(/youtube\.com\/watch\?v=([^&]+)/);
|
|
||||||
if(m) {
|
if(m) {
|
||||||
// Extract ID
|
// Extract ID
|
||||||
return m[1];
|
return m[1];
|
||||||
}
|
}
|
||||||
var m = url.match(/youtu\.be\/([^&]+)/);
|
var m = url.match(/youtu\.be\/([^&#]+)/);
|
||||||
if(m) {
|
if(m) {
|
||||||
// Extract ID
|
// Extract ID
|
||||||
return m[1];
|
return m[1];
|
||||||
}
|
}
|
||||||
// Final try
|
// Final try
|
||||||
var m = url.match(/v=([^&]*)/);
|
var m = url.match(/([^&#]*)/);
|
||||||
if(m) {
|
if(m) {
|
||||||
// Extract ID
|
// Extract ID
|
||||||
return m[1];
|
return m[1];
|
||||||
|
@ -727,6 +725,12 @@ function updateChatFilters(entries) {
|
||||||
.appendTo($("<td/>").appendTo(newfilt));
|
.appendTo($("<td/>").appendTo(newfilt));
|
||||||
var cback = (function(regex, replace) { return function() {
|
var cback = (function(regex, replace) { return function() {
|
||||||
if(regex.val() && replace.val()) {
|
if(regex.val() && replace.val()) {
|
||||||
|
try {
|
||||||
|
var dummy = new RegExp(regex.val(), "g");
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
alert("Invalid regex: " + e);
|
||||||
|
}
|
||||||
socket.emit("chatFilter", {
|
socket.emit("chatFilter", {
|
||||||
cmd: "update",
|
cmd: "update",
|
||||||
filter: [regex.val(), replace.val(), true]
|
filter: [regex.val(), replace.val(), true]
|
||||||
|
|
Loading…
Reference in New Issue