mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Fix for error on video not always skipping
This commit is contained in:
		| @@ -184,14 +184,14 @@ function skip(list, guid, coll, offline, socket, callback) { | |||||||
|                 list.userpass = crypto.createHash('sha256').update(Functions.decrypt_string(list.userpass)).digest("base64"); |                 list.userpass = crypto.createHash('sha256').update(Functions.decrypt_string(list.userpass)).digest("base64"); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             db.collection(coll + "_settings").find(function(err, docs){ |             db.collection(coll + "_settings").find(function(_err, docs){ | ||||||
|                 if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == list.userpass))) { |                 if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == list.userpass))) { | ||||||
|                     Functions.check_inlist(coll, guid, socket, offline, undefined, "place 12"); |                     Functions.check_inlist(coll, guid, socket, offline, undefined, "place 12"); | ||||||
|  |  | ||||||
|                     var video_id; |                     var video_id; | ||||||
|                     adminpass = ""; |                     adminpass = ""; | ||||||
|                     video_id  = list.id; |                     video_id  = list.id; | ||||||
|                     err       = list.error; |                     var err       = list.error; | ||||||
|                     Search.check_if_error_or_blocked(video_id, coll, err == "5" || err == "100" || err == "101" || err == "150" || err == 5 || err == 100 || err == 101 || err == 150, function(trueError) { |                     Search.check_if_error_or_blocked(video_id, coll, err == "5" || err == "100" || err == "101" || err == "150" || err == 5 || err == 100 || err == 101 || err == 150, function(trueError) { | ||||||
|                         var error = false; |                         var error = false; | ||||||
|                         if (!trueError) { |                         if (!trueError) { | ||||||
| @@ -210,11 +210,11 @@ function skip(list, guid, coll, offline, socket, callback) { | |||||||
|                             if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error) |                             if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error) | ||||||
|                             { |                             { | ||||||
|                                 db.collection("frontpage_lists").find({"_id": coll}, function(err, frontpage_viewers){ |                                 db.collection("frontpage_lists").find({"_id": coll}, function(err, frontpage_viewers){ | ||||||
|                                     if( |                                     if(error || | ||||||
|                                         (strictSkip && (error || (docs[0].adminpass == hash && docs[0].adminpass !== "") || (docs[0].skips.length+1 >= strictSkipNumber))) || |                                         ((strictSkip && ((docs[0].adminpass == hash && docs[0].adminpass !== "") || (docs[0].skips.length+1 >= strictSkipNumber))) || | ||||||
|                                         (!strictSkip && ((frontpage_viewers[0].viewers/2 <= docs[0].skips.length+1 && !Functions.contains(docs[0].skips, guid) && frontpage_viewers[0].viewers != 2) || |                                         (!strictSkip && ((frontpage_viewers[0].viewers/2 <= docs[0].skips.length+1 && !Functions.contains(docs[0].skips, guid) && frontpage_viewers[0].viewers != 2) || | ||||||
|                                             (frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) || |                                             (frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) || | ||||||
|                                             (docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip)))) |                                             (docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip))))) | ||||||
|                                     { |                                     { | ||||||
|                                         Functions.checkTimeout("skip", 1, coll, coll, error, true, socket, function() { |                                         Functions.checkTimeout("skip", 1, coll, coll, error, true, socket, function() { | ||||||
|                                             change_song(coll, error, video_id, docs); |                                             change_song(coll, error, video_id, docs); | ||||||
| @@ -403,13 +403,13 @@ function change_song_post(coll, next_song, conf, callback, socket, removed) { | |||||||
|                 }, function(err, returnDocs){ |                 }, function(err, returnDocs){ | ||||||
|                     //db.collection(coll + "_settings").find({id: "config"}, function(err, conf){ |                     //db.collection(coll + "_settings").find({id: "config"}, function(err, conf){ | ||||||
|                         if(!callback) { |                         if(!callback) { | ||||||
|                             io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed}); |                             io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id}); | ||||||
|                             send_play(coll); |                             send_play(coll); | ||||||
|                         } else { |                         } else { | ||||||
|                             if(socket == undefined) { |                             if(socket == undefined) { | ||||||
|                                 io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed}); |                                 io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id}); | ||||||
|                             } else { |                             } else { | ||||||
|                                 socket.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed}); |                                 socket.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay || removed, id: id}); | ||||||
|                             } |                             } | ||||||
|                             send_play(coll, socket, true); |                             send_play(coll, socket, true); | ||||||
|                             callback(); |                             callback(); | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ function check_if_error_or_blocked(id, channel, errored, callback) { | |||||||
|                         callback(true); |                         callback(true); | ||||||
|                         return; |                         return; | ||||||
|                     } else if(resp.items[0].contentDetails.hasOwnProperty("licensedContent") && |                     } else if(resp.items[0].contentDetails.hasOwnProperty("licensedContent") && | ||||||
|                               !resp.items[0].contentDetails.licensedContent) { |                               resp.items[0].contentDetails.licensedContent) { | ||||||
|                         callback(true); |                         callback(true); | ||||||
|                         return; |                         return; | ||||||
|                     } else if(resp.items[0].contentDetails.hasOwnProperty("regionRestriction") && |                     } else if(resp.items[0].contentDetails.hasOwnProperty("regionRestriction") && | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ var List = { | |||||||
|                 break; |                 break; | ||||||
|             case "song_change": |             case "song_change": | ||||||
|                 if((offline && msg.offline_change) || !offline) { |                 if((offline && msg.offline_change) || !offline) { | ||||||
|                     if(window.location.pathname != "/") List.song_change(msg.time, msg.remove); |                     if(window.location.pathname != "/") List.song_change(msg.time, msg.remove, msg.id); | ||||||
|                     if(full_playlist.length > 0) { |                     if(full_playlist.length > 0) { | ||||||
|                         Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail}); |                         Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail}); | ||||||
|                     } |                     } | ||||||
| @@ -584,14 +584,16 @@ var List = { | |||||||
|         List.insertAtIndex(full_playlist[0], false, true); |         List.insertAtIndex(full_playlist[0], false, true); | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     song_change: function(time, remove) { |     song_change: function(time, remove, id) { | ||||||
|         try{ |         try{ | ||||||
|             var length = full_playlist.length - 1; |             var length = full_playlist.length - 1; | ||||||
|  |  | ||||||
|             if(full_playlist.length <= 1) { |             if(full_playlist.length <= 1) { | ||||||
|                 List.empty = true; |                 List.empty = true; | ||||||
|                 Helper.setHtml("#wrapper", "<span id='empty-channel-message'>The playlist is empty.</span>"); |                 Helper.setHtml("#wrapper", "<span id='empty-channel-message'>The playlist is empty.</span>"); | ||||||
|             } |             } | ||||||
|  |             if(id != full_playlist[0].id) { | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|             var newLast = full_playlist[0]; |             var newLast = full_playlist[0]; | ||||||
|             full_playlist[0].now_playing        = true; |             full_playlist[0].now_playing        = true; | ||||||
|             full_playlist[0].votes              = 0; |             full_playlist[0].votes              = 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user