mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Merge pull request #346 from zoff-music/feature/testing-chromecast-fixes
Feature/testing chromecast fixes
This commit is contained in:
@@ -62,6 +62,7 @@ function getSession(socket) {
|
|||||||
var cookie = require("cookie");
|
var cookie = require("cookie");
|
||||||
var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
|
var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
|
||||||
return parsedCookies["_uI"];*/
|
return parsedCookies["_uI"];*/
|
||||||
|
if(socket.cookie_id == undefined) throw "Undefined error";
|
||||||
return socket.cookie_id;
|
return socket.cookie_id;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return "empty";
|
return "empty";
|
||||||
@@ -252,6 +253,22 @@ function getSessionChatPass(id, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setChromecastHost(id, other_id, list, callback) {
|
||||||
|
try {
|
||||||
|
if(id == "empty" || id == undefined) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
connected_db.collection(id).update({_id: list}, {"chromecast": true, id: other_id}, {upsert: true}, function(e, docs) {
|
||||||
|
callback(true);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setSessionUserPass(id, userpass, list, callback) {
|
function setSessionUserPass(id, userpass, list, callback) {
|
||||||
try {
|
try {
|
||||||
if(id == "empty" || id == undefined) {
|
if(id == "empty" || id == undefined) {
|
||||||
@@ -277,10 +294,16 @@ function getSessionAdminUser(id, list, callback) {
|
|||||||
var userpass = "";
|
var userpass = "";
|
||||||
var adminpass = "";
|
var adminpass = "";
|
||||||
if(d.length > 0) {
|
if(d.length > 0) {
|
||||||
if(d[0].userpass != undefined) userpass = d[0].userpass;
|
if(d[0].hasOwnProperty("chromecast") && d[0].chromecast) {
|
||||||
if(d[0].adminpass != undefined) adminpass = d[0].adminpass;
|
getSessionAdminUser(d[0].id, list, callback);
|
||||||
|
} else {
|
||||||
|
if(d[0].userpass != undefined) userpass = d[0].userpass;
|
||||||
|
if(d[0].adminpass != undefined) adminpass = d[0].adminpass;
|
||||||
|
callback(userpass, adminpass, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback(userpass, adminpass, true);
|
||||||
}
|
}
|
||||||
callback(userpass, adminpass, true);
|
|
||||||
})
|
})
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
callback("", "", false);
|
callback("", "", false);
|
||||||
@@ -310,6 +333,7 @@ function removeSessionAdminPass(id, channel, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.setChromecastHost = setChromecastHost;
|
||||||
module.exports.decodeChannelName = decodeChannelName;
|
module.exports.decodeChannelName = decodeChannelName;
|
||||||
module.exports.encodeChannelName = encodeChannelName;
|
module.exports.encodeChannelName = encodeChannelName;
|
||||||
module.exports.isUrl = isUrl;
|
module.exports.isUrl = isUrl;
|
||||||
|
|||||||
@@ -82,22 +82,24 @@ module.exports = function() {
|
|||||||
try {
|
try {
|
||||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") &&
|
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") &&
|
||||||
msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" &&
|
msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" &&
|
||||||
typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string") {
|
typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") {
|
||||||
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
|
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
|
||||||
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
|
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
|
||||||
socket.cookie_id = msg.guid;
|
|
||||||
guid = msg.guid;
|
|
||||||
socketid = msg.socket_id;
|
|
||||||
socket.zoff_id = socketid;
|
|
||||||
if(msg.hasOwnProperty("channel")) {
|
|
||||||
msg.channel = Functions.encodeChannelName(msg.channel);
|
|
||||||
}
|
|
||||||
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
if(coll.indexOf("?") > -1){
|
if(coll.indexOf("?") > -1){
|
||||||
coll = coll.substring(0, coll.indexOf("?"));
|
coll = coll.substring(0, coll.indexOf("?"));
|
||||||
}
|
}
|
||||||
|
Functions.setChromecastHost(socket.cookie_id, msg.socket_id, msg.channel, function(results) {
|
||||||
|
});
|
||||||
|
//socket.cookie_id = msg.guid;
|
||||||
|
guid = msg.guid;
|
||||||
|
socketid = msg.socket_id;
|
||||||
|
socket.zoff_id = socketid;
|
||||||
|
if(msg.hasOwnProperty("channel")) {
|
||||||
|
msg.channel = Functions.encodeChannelName(msg.channel);
|
||||||
|
}
|
||||||
in_list = true;
|
in_list = true;
|
||||||
chromecast_object = true;
|
chromecast_object = true;
|
||||||
socket.join(coll);
|
socket.join(coll);
|
||||||
@@ -110,7 +112,7 @@ module.exports = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("get_id", function() {
|
socket.on("get_id", function() {
|
||||||
socket.emit("id_chromecast", Functions.getSession(socket));
|
socket.emit("id_chromecast", {cookie_id: Functions.getSession(socket), guid: guid});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("error_video", function(msg) {
|
socket.on("error_video", function(msg) {
|
||||||
@@ -674,7 +676,7 @@ module.exports = function() {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(coll == undefined) return;
|
||||||
db.collection(coll + "_settings").find(function(err, docs) {
|
db.collection(coll + "_settings").find(function(err, docs) {
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(userpass != "" || obj.pass == undefined) {
|
if(userpass != "" || obj.pass == undefined) {
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ function get_list_listener(){
|
|||||||
});
|
});
|
||||||
socket.on("id_chromecast", function(msg) {
|
socket.on("id_chromecast", function(msg) {
|
||||||
chromecast_specs_sent = true;
|
chromecast_specs_sent = true;
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg, socketid: socket.id})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: msg.guid, socketid: msg.cookie_id, channel: chan.toLowerCase()})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ initializeCastApi = function() {
|
|||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
||||||
|
|
||||||
if(Helper.mobilecheck() && !chromecast_specs_sent) {
|
if(Helper.mobilecheck()) {
|
||||||
socket.emit("get_id");
|
socket.emit("get_id");
|
||||||
}
|
}
|
||||||
hide_native(1);
|
hide_native(1);
|
||||||
@@ -322,6 +322,9 @@ initializeCastApi = function() {
|
|||||||
} catch(event){
|
} catch(event){
|
||||||
_seekTo = seekTo;
|
_seekTo = seekTo;
|
||||||
}
|
}
|
||||||
|
if(Helper.mobilecheck()) {
|
||||||
|
socket.emit("get_id");
|
||||||
|
}
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
||||||
hide_native(1);
|
hide_native(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user