mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Improved finding errorounus songs, and fix error with embedded player
This commit is contained in:
@@ -89,11 +89,11 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
db.collection(coll).update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
db.collection(coll).update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
||||||
List.send_play(coll, undefined);
|
List.send_play(coll, undefined);
|
||||||
Frontpage.update_frontpage(coll, id, title);
|
Frontpage.update_frontpage(coll, id, title);
|
||||||
Search.get_correct_info(new_song, coll, false);
|
if(!full_list) Search.get_correct_info(new_song, coll, false);
|
||||||
} else {
|
} else {
|
||||||
var new_song = {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration};
|
var new_song = {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration};
|
||||||
io.to(coll).emit("channel", {type: "added", value: new_song});
|
io.to(coll).emit("channel", {type: "added", value: new_song});
|
||||||
Search.get_correct_info(new_song, coll, true);
|
if(!full_list) Search.get_correct_info(new_song, coll, true);
|
||||||
}
|
}
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
List.getNextSong(coll);
|
List.getNextSong(coll);
|
||||||
|
|||||||
@@ -8,35 +8,38 @@ function get_correct_info(song_generated, channel, broadcast) {
|
|||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
||||||
|
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body) {
|
||||||
var resp = JSON.parse(body);
|
try {
|
||||||
if(resp.items.length == 1) {
|
var resp = JSON.parse(body);
|
||||||
var duration = parseInt(durationToSeconds(resp.items[0].contentDetails.duration));
|
if(resp.items.length == 1) {
|
||||||
var title = resp.items[0].snippet.localized.title;
|
var duration = parseInt(durationToSeconds(resp.items[0].contentDetails.duration));
|
||||||
if(title != song_generated.title || duration < parseInt(song_generated.duration)) {
|
var title = resp.items[0].snippet.localized.title;
|
||||||
if(title != song_generated.title) {
|
if(title != song_generated.title || duration < parseInt(song_generated.duration)) {
|
||||||
song_generated.title = title;
|
if(title != song_generated.title) {
|
||||||
}
|
song_generated.title = title;
|
||||||
if(duration < parseInt(song_generated.duration)) {
|
|
||||||
song_generated.duration = duration;
|
|
||||||
song_generated.start = 0;
|
|
||||||
song_generated.end = duration;
|
|
||||||
}
|
|
||||||
db.collection(channel).update({"id": song_generated.id}, {
|
|
||||||
$set: {
|
|
||||||
"duration": song_generated.duration,
|
|
||||||
"start": song_generated.start,
|
|
||||||
"end": song_generated.end,
|
|
||||||
"title": song_generated.title,
|
|
||||||
}
|
}
|
||||||
}, function(err, docs) {
|
if(duration < parseInt(song_generated.duration)) {
|
||||||
if(broadcast && docs.nModified == 1) {
|
song_generated.duration = duration;
|
||||||
song_generated.new_id = song_generated.id;
|
song_generated.start = 0;
|
||||||
io.to(channel).emit("channel", {type: "changed_values", value: song_generated});
|
song_generated.end = duration;
|
||||||
}
|
}
|
||||||
});
|
db.collection(channel).update({"id": song_generated.id}, {
|
||||||
|
$set: {
|
||||||
|
"duration": song_generated.duration,
|
||||||
|
"start": song_generated.start,
|
||||||
|
"end": song_generated.end,
|
||||||
|
"title": song_generated.title,
|
||||||
|
}
|
||||||
|
}, function(err, docs) {
|
||||||
|
if(broadcast && docs.nModified == 1) {
|
||||||
|
song_generated.new_id = song_generated.id;
|
||||||
|
io.to(channel).emit("channel", {type: "changed_values", value: song_generated});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(e){
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,53 +54,57 @@ function check_error_video(msg, channel) {
|
|||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key="+key+"&id=" + msg.id,
|
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key="+key+"&id=" + msg.id,
|
||||||
|
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body) {
|
||||||
var resp = JSON.parse(body);
|
try {
|
||||||
if(resp.pageInfo.totalResults == 0) {
|
var resp = JSON.parse(body);
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+key+"&videoEmbeddable=true&part=id&type=video&order=viewCount&safeSearch=none&maxResults=5&q=" + encodeURIComponent(msg.title);
|
if(resp.pageInfo.totalResults == 0) {
|
||||||
request({
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+key+"&videoEmbeddable=true&part=id&type=video&order=viewCount&safeSearch=none&maxResults=5&q=" + encodeURIComponent(msg.title);
|
||||||
method: "GET",
|
request({
|
||||||
url: yt_url,
|
method: "GET",
|
||||||
}, function(error, response, body){
|
url: yt_url,
|
||||||
var resp = JSON.parse(body);
|
}, function(error, response, body){
|
||||||
if(resp.items.length > 0) {
|
var resp = JSON.parse(body);
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=";
|
if(resp.items.length > 0) {
|
||||||
for(var i = 0; i < resp.items.length; i++) {
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=";
|
||||||
vid_url += resp.items[i].id.videoId + ",";
|
|
||||||
}
|
|
||||||
request({
|
|
||||||
type: "GET",
|
|
||||||
url: vid_url
|
|
||||||
}, function(error, response, body) {
|
|
||||||
var resp = JSON.parse(body);
|
|
||||||
var found = false;
|
|
||||||
var element = {};
|
|
||||||
for(var i = 0; i < resp.items.length; i++) {
|
for(var i = 0; i < resp.items.length; i++) {
|
||||||
if(similarity(resp.items[i].snippet.localized.title, msg.title) > 0.75) {
|
vid_url += resp.items[i].id.videoId + ",";
|
||||||
found = true;
|
}
|
||||||
element = {
|
request({
|
||||||
title: resp.items[i].snippet.localized.title,
|
type: "GET",
|
||||||
duration: parseInt(durationToSeconds(resp.items[i].contentDetails.duration)),
|
url: vid_url
|
||||||
id: resp.items[i].id,
|
}, function(error, response, body) {
|
||||||
start: 0,
|
var resp = JSON.parse(body);
|
||||||
end: parseInt(durationToSeconds(resp.items[i].contentDetails.duration)),
|
var found = false;
|
||||||
|
var element = {};
|
||||||
|
for(var i = 0; i < resp.items.length; i++) {
|
||||||
|
if(similarity(resp.items[i].snippet.localized.title, msg.title) > 0.75) {
|
||||||
|
found = true;
|
||||||
|
element = {
|
||||||
|
title: resp.items[i].snippet.localized.title,
|
||||||
|
duration: parseInt(durationToSeconds(resp.items[i].contentDetails.duration)),
|
||||||
|
id: resp.items[i].id,
|
||||||
|
start: 0,
|
||||||
|
end: parseInt(durationToSeconds(resp.items[i].contentDetails.duration)),
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
if(found) {
|
||||||
if(found) {
|
db.collection(channel).update({"id": msg.id}, {
|
||||||
db.collection(channel).update({"id": msg.id}, {
|
$set: element
|
||||||
$set: element
|
}, function(err, docs) {
|
||||||
}, function(err, docs) {
|
if(docs.nModified == 1) {
|
||||||
if(docs.nModified == 1) {
|
element.new_id = element.id;
|
||||||
element.new_id = element.id;
|
element.id = msg.id;
|
||||||
element.id = msg.id;
|
io.to(channel).emit("channel", {type: "changed_values", value: element});
|
||||||
io.to(channel).emit("channel", {type: "changed_values", value: element});
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
catch(e){
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<link type="text/css" rel="stylesheet" href="/assets/css/materialize.min.css" />
|
<link type="text/css" rel="stylesheet" href="/assets/css/materialize.min.css" />
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
<script type="text/javascript" src="/assets/dist/lib/jquery-2.1.3.min.js"></script>
|
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
|
||||||
<script type="text/javascript" src="/assets/dist/lib/materialize.min.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
|
||||||
<script type="text/javascript" src="/assets/dist/lib/jquery-ui-1.10.3.min.js"></script>
|
<script type="text/javascript" src="/assets/dist/lib/jquery-ui.min.js"></script>
|
||||||
<script type="text/javascript" src="/assets/dist/lib/socket.io.min.js"></script>
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
|
||||||
<link type="text/css" rel="stylesheet" href="/assets/css/embed.css" />
|
<link type="text/css" rel="stylesheet" href="/assets/css/embed.css" />
|
||||||
<script src="/assets/dist/embed.min.js"></script>
|
<script src="/assets/dist/embed.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
var slider_type = "horizontal";
|
||||||
|
var timed_remove_check;
|
||||||
|
var gotten_np = false;
|
||||||
var song_title = "";
|
var song_title = "";
|
||||||
var paused = false;
|
var paused = false;
|
||||||
var player_ready = false;
|
var player_ready = false;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ var List = {
|
|||||||
|
|
||||||
changedValues: function(song) {
|
changedValues: function(song) {
|
||||||
var i = List.getIndexOfSong(song.id);
|
var i = List.getIndexOfSong(song.id);
|
||||||
if(i >= 0) {
|
if(i >= 0 && window.location.pathname != "/") {
|
||||||
full_playlist[i].title = song.title;
|
full_playlist[i].title = song.title;
|
||||||
full_playlist[i].duration = song.duration;
|
full_playlist[i].duration = song.duration;
|
||||||
full_playlist[i].start = song.start;
|
full_playlist[i].start = song.start;
|
||||||
@@ -289,26 +289,34 @@ var List = {
|
|||||||
$("#settings").css("opacity", "1");
|
$("#settings").css("opacity", "1");
|
||||||
$("#wrapper").css("opacity", "1");
|
$("#wrapper").css("opacity", "1");
|
||||||
|
|
||||||
clearTimeout(timed_remove_check);
|
if(!embed) {
|
||||||
timed_remove_check = setTimeout(function() {
|
clearTimeout(timed_remove_check);
|
||||||
$.each(full_playlist, function(j, _current_song) {
|
timed_remove_check = setTimeout(function() {
|
||||||
$.getJSON('https://www.googleapis.com/youtube/v3/videos?id=' + _current_song.id
|
if(full_playlist.length > 0) {
|
||||||
+ "&key=" + api_key + "&part=snippet",
|
List.check_error_videos(0);
|
||||||
function (data, status, xhr) {
|
}
|
||||||
if (data.items.length == 0) {
|
}, 1500);
|
||||||
setTimeout(function() {
|
}
|
||||||
socket.emit("error_video", {channel: chan.toLowerCase(), id: _current_song.id, title: _current_song.title});
|
},
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).error(function (xhr, errorType, exception) {
|
check_error_videos: function(i) {
|
||||||
//var errorMessage = exception || xhr.statusText || xhr.responseText;
|
console.log(i);
|
||||||
setTimeout(function() {
|
$.getJSON('https://www.googleapis.com/youtube/v3/videos?id=' + full_playlist[i].id
|
||||||
socket.emit("error_video", {channel: chan.toLowerCase(), id: _current_song.id, title: _current_song.title});
|
+ "&key=" + api_key + "&part=snippet",
|
||||||
}, 500);
|
function (data, status, xhr) {
|
||||||
});
|
if (data.items.length == 0) {
|
||||||
|
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
||||||
|
}
|
||||||
|
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
||||||
|
List.check_error_videos(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}).error(function (xhr, errorType, exception) {
|
||||||
|
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
||||||
|
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
||||||
|
List.check_error_videos(i + 1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 1500);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
dynamicContentPageJumpTo: function(page) {
|
dynamicContentPageJumpTo: function(page) {
|
||||||
|
|||||||
@@ -594,6 +594,12 @@ var Player = {
|
|||||||
//currDurr = currDurr - Player.np.start;
|
//currDurr = currDurr - Player.np.start;
|
||||||
minutes = Math.floor(currDurr / 60);
|
minutes = Math.floor(currDurr / 60);
|
||||||
seconds = currDurr - (minutes * 60);
|
seconds = currDurr - (minutes * 60);
|
||||||
|
/*if(isNan(minutes)) {
|
||||||
|
minutes = 0;
|
||||||
|
}
|
||||||
|
if(isNan(seconds)) {
|
||||||
|
seconds = 0;
|
||||||
|
}*/
|
||||||
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
|
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
|
||||||
per = (100 / duration) * currDurr;
|
per = (100 / duration) * currDurr;
|
||||||
if(per >= 100) {
|
if(per >= 100) {
|
||||||
|
|||||||
Reference in New Issue
Block a user