mirror of https://github.com/calzoneman/sync.git
Fixes
This commit is contained in:
parent
5a9b3128d1
commit
824a313b19
4
acp.js
4
acp.js
|
@ -115,14 +115,14 @@ module.exports = function (Server) {
|
||||||
|
|
||||||
user.socket.on("acp-list-loaded", function() {
|
user.socket.on("acp-list-loaded", function() {
|
||||||
var chans = [];
|
var chans = [];
|
||||||
var all = Server.getAllChannels();
|
var all = Server.channels;
|
||||||
for(var c in all) {
|
for(var c in all) {
|
||||||
var chan = all[c];
|
var chan = all[c];
|
||||||
if(!chan)
|
if(!chan)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
chans.push({
|
chans.push({
|
||||||
name: c,
|
name: chan.name,
|
||||||
title: chan.opts.pagetitle,
|
title: chan.opts.pagetitle,
|
||||||
usercount: chan.users.length,
|
usercount: chan.users.length,
|
||||||
mediatitle: chan.playlist.current ? chan.playlist.current.media.title : "-",
|
mediatitle: chan.playlist.current ? chan.playlist.current.media.title : "-",
|
||||||
|
|
47
api.js
47
api.js
|
@ -28,26 +28,10 @@ function getIP(req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function (Server) {
|
module.exports = function (Server) {
|
||||||
return {
|
var API = function () {
|
||||||
plainHandlers: {
|
|
||||||
"readlog" : this.handleReadLog
|
|
||||||
},
|
|
||||||
|
|
||||||
jsonHandlers: {
|
|
||||||
"channeldata" : this.handleChannelData,
|
|
||||||
"listloaded" : this.handleChannelList,
|
|
||||||
"login" : this.handleLogin,
|
|
||||||
"register" : this.handleRegister,
|
|
||||||
"changepass" : this.handlePasswordChange,
|
|
||||||
"resetpass" : this.handlePasswordReset,
|
|
||||||
"recoverpw" : this.handlePasswordRecover,
|
|
||||||
"setprofile" : this.handleProfileChange,
|
|
||||||
"getprofile" : this.handleProfileGet,
|
|
||||||
"setemail" : this.handleEmailChange,
|
|
||||||
"admreports" : this.handleAdmReports,
|
|
||||||
"readactionlog" : this.handleReadActionLog
|
|
||||||
},
|
|
||||||
|
|
||||||
|
}
|
||||||
|
API.prototype = {
|
||||||
handle: function (path, req, res) {
|
handle: function (path, req, res) {
|
||||||
var parts = path.split("/");
|
var parts = path.split("/");
|
||||||
var last = parts[parts.length - 1];
|
var last = parts[parts.length - 1];
|
||||||
|
@ -576,11 +560,34 @@ module.exports = function (Server) {
|
||||||
else {
|
else {
|
||||||
res.send(404);
|
res.send(404);
|
||||||
}
|
}
|
||||||
});
|
}.bind(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.send(400);
|
res.send(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var api = new API();
|
||||||
|
|
||||||
|
api.plainHandlers = {
|
||||||
|
"readlog" : api.handleReadLog.bind(api)
|
||||||
|
};
|
||||||
|
|
||||||
|
api.jsonHandlers = {
|
||||||
|
"channeldata" : api.handleChannelData.bind(api),
|
||||||
|
"listloaded" : api.handleChannelList.bind(api),
|
||||||
|
"login" : api.handleLogin.bind(api),
|
||||||
|
"register" : api.handleRegister.bind(api),
|
||||||
|
"changepass" : api.handlePasswordChange.bind(api),
|
||||||
|
"resetpass" : api.handlePasswordReset.bind(api),
|
||||||
|
"recoverpw" : api.handlePasswordRecover.bind(api),
|
||||||
|
"setprofile" : api.handleProfileChange.bind(api),
|
||||||
|
"getprofile" : api.handleProfileGet.bind(api),
|
||||||
|
"setemail" : api.handleEmailChange.bind(api),
|
||||||
|
"admreports" : api.handleAdmReports.bind(api),
|
||||||
|
"readactionlog" : api.handleReadActionLog.bind(api)
|
||||||
|
};
|
||||||
|
|
||||||
|
return api;
|
||||||
}
|
}
|
||||||
|
|
|
@ -647,8 +647,7 @@ Channel.prototype.userLeave = function(user) {
|
||||||
this.logger.log("--- /" + user.ip + " (" + user.name + ") left");
|
this.logger.log("--- /" + user.ip + " (" + user.name + ") left");
|
||||||
if(this.users.length == 0) {
|
if(this.users.length == 0) {
|
||||||
this.logger.log("*** Channel empty, unloading");
|
this.logger.log("*** Channel empty, unloading");
|
||||||
var name = this.name;
|
this.server.unloadChannel(this);
|
||||||
this.server.unload(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1203,6 +1202,10 @@ Channel.prototype.tryQueue = function(user, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.addMedia = function(data, user) {
|
Channel.prototype.addMedia = function(data, user) {
|
||||||
|
if(data.type === "yp" && !this.hasPermission(user, "playlistaddlist")) {
|
||||||
|
user.socket.emit("queueFail", "You don't have permission to add playlists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
data.temp = isLive(data.type) || !this.hasPermission(user, "addnontemp");
|
data.temp = isLive(data.type) || !this.hasPermission(user, "addnontemp");
|
||||||
data.maxlength = this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength;
|
data.maxlength = this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength;
|
||||||
var chan = this;
|
var chan = this;
|
||||||
|
|
|
@ -35,6 +35,11 @@ function getJSONInternal(transport, options, callback) {
|
||||||
m = buffer.match(/([0-9]+ not found)/);
|
m = buffer.match(/([0-9]+ not found)/);
|
||||||
Logger.errlog.log("Media request failed: "+options.host+options.path);
|
Logger.errlog.log("Media request failed: "+options.host+options.path);
|
||||||
if(m) {
|
if(m) {
|
||||||
|
if(m[1] === "too_many_recent_calls") {
|
||||||
|
m[1] = "YouTube is throttling the server right "+
|
||||||
|
"now for making too many requests. "+
|
||||||
|
"Please try again in a moment.";
|
||||||
|
}
|
||||||
Logger.errlog.log("Reason: " + m[1]);
|
Logger.errlog.log("Reason: " + m[1]);
|
||||||
callback(m[1], res.statusCode, null);
|
callback(m[1], res.statusCode, null);
|
||||||
}
|
}
|
||||||
|
|
12
playlist.js
12
playlist.js
|
@ -35,7 +35,7 @@ PlaylistItem.prototype.pack = function() {
|
||||||
function Playlist(chan) {
|
function Playlist(chan) {
|
||||||
if(chan.name in AllPlaylists && AllPlaylists[chan.name]) {
|
if(chan.name in AllPlaylists && AllPlaylists[chan.name]) {
|
||||||
var pl = AllPlaylists[chan.name];
|
var pl = AllPlaylists[chan.name];
|
||||||
if("_leadInterval" in pl)
|
if(!pl.dead)
|
||||||
pl.die();
|
pl.die();
|
||||||
}
|
}
|
||||||
this.items = new ULList();
|
this.items = new ULList();
|
||||||
|
@ -130,6 +130,7 @@ Playlist.prototype.die = function () {
|
||||||
}
|
}
|
||||||
for(var key in this)
|
for(var key in this)
|
||||||
delete this[key];
|
delete this[key];
|
||||||
|
this.dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Playlist.prototype.load = function(data, callback) {
|
Playlist.prototype.load = function(data, callback) {
|
||||||
|
@ -272,6 +273,8 @@ Playlist.prototype.addMediaList = function(data, callback) {
|
||||||
var x = data.list[i];
|
var x = data.list[i];
|
||||||
(function(i, x) {
|
(function(i, x) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
if(pl.dead)
|
||||||
|
return;
|
||||||
x.queueby = data.queueby;
|
x.queueby = data.queueby;
|
||||||
x.pos = data.pos;
|
x.pos = data.pos;
|
||||||
if(start && x == start) {
|
if(start && x == start) {
|
||||||
|
@ -310,7 +313,14 @@ Playlist.prototype.addYouTubePlaylist = function(data, callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data.pos === "next")
|
||||||
|
vids.reverse();
|
||||||
|
|
||||||
vids.forEach(function(media) {
|
vids.forEach(function(media) {
|
||||||
|
if(data.maxlength && media.seconds > data.maxlength) {
|
||||||
|
callback("Media is too long!", null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var it = pl.makeItem(media);
|
var it = pl.makeItem(media);
|
||||||
it.temp = data.temp;
|
it.temp = data.temp;
|
||||||
it.queueby = data.queueby;
|
it.queueby = data.queueby;
|
||||||
|
|
|
@ -84,7 +84,7 @@ var Server = {
|
||||||
this.api = require("./api")(this);
|
this.api = require("./api")(this);
|
||||||
this.app.get("/api/:apireq(*)", function (req, res, next) {
|
this.app.get("/api/:apireq(*)", function (req, res, next) {
|
||||||
this.api.handle(req.url.substring(5), req, res);
|
this.api.handle(req.url.substring(5), req, res);
|
||||||
});
|
}.bind(this));
|
||||||
|
|
||||||
// default path
|
// default path
|
||||||
this.app.get("/:thing(*)", function (req, res, next) {
|
this.app.get("/:thing(*)", function (req, res, next) {
|
||||||
|
@ -121,7 +121,7 @@ var Server = {
|
||||||
|
|
||||||
socket.on("disconnect", function () {
|
socket.on("disconnect", function () {
|
||||||
this.ips[ip]--;
|
this.ips[ip]--;
|
||||||
});
|
}.bind(this));
|
||||||
|
|
||||||
if(!(ip in this.ips))
|
if(!(ip in this.ips))
|
||||||
this.ips[ip] = 0;
|
this.ips[ip] = 0;
|
||||||
|
|
Loading…
Reference in New Issue