Updated thumbnailchecking

- Borrowing youtube 404 image for now if someone tries to trick the server to use other thumbnail than soundlcoud thumbnail when adding soundcloud song
- Setting thumbnail in db even for youtube-videos, for more consistency
This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-29 15:02:09 +02:00
parent 51a5cc2b13
commit adc55ee420
5 changed files with 42 additions and 23 deletions

View File

@@ -245,23 +245,26 @@ var List = {
check_error_videos: function(i) {
//Helper.log("Empty-checker at " + i);
if(full_playlist.length == 0 || full_playlist[i].source == "soundcloud") return;
Helper.ajax({
method: "get",
url: 'https://www.googleapis.com/youtube/v3/videos?id=' + full_playlist[i].id
+ "&key=" + api_key + "&part=snippet",
success: function (data) {
data = JSON.parse(data);
//Helper.log("Empty-checker items " + data.items.length);
if (data.items.length == 0) {
Helper.log(["Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title]);
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title, source: full_playlist[i].source});
if(full_playlist.length == 0) return;
else if(full_playlist[i].source == "soundcloud" && full_playlist.length > i + 1 && window.location.pathname != "/") List.check_error_videos(i + 1);
else {
Helper.ajax({
method: "get",
url: 'https://www.googleapis.com/youtube/v3/videos?id=' + full_playlist[i].id
+ "&key=" + api_key + "&part=snippet",
success: function (data) {
data = JSON.parse(data);
//Helper.log("Empty-checker items " + data.items.length);
if (data.items.length == 0) {
Helper.log(["Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title]);
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title, source: full_playlist[i].source});
}
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
List.check_error_videos(i + 1);
}
}
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
List.check_error_videos(i + 1);
}
}
})
});
}
},
dynamicContentPageJumpTo: function(page) {

View File

@@ -1306,7 +1306,7 @@ addListener("click", ".result-object", function(e){
var start = parseInt(e.querySelector(".result-start").value);
var end = parseInt(e.querySelector(".result-end").value);
var source = "youtube";
var thumbnail;
var thumbnail = "https://img.youtube.com/vi/" + id + "/mqdefault.jpg";
if(e.getAttribute("data-type-source") != undefined) {
source = "soundcloud";
thumbnail = e.getAttribute("data-type-thumbnail");

View File

@@ -372,7 +372,7 @@ var Search = {
if((!not_matched)){
matched = true;
Search.readySubmit(true, { id: data.id, title: data.snippet.title, source: "youtube", duration: duration, totalLength: totalNumber - 1});
Search.readySubmit(true, { id: data.id, title: data.snippet.title, source: "youtube", thumbnail: "https://img.youtube.com/vi/" + data.id + "/mqdefault.jpg", duration: duration, totalLength: totalNumber - 1});
break;
}
}
@@ -615,7 +615,7 @@ addVideos: function(ids){
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
//Search.submit(song.id, enc_title, duration, playlist, i);
x += 1;
Search.submitYouTubeArray.push({id: song.id, title: enc_title, duration: duration});
Search.submitYouTubeArray.push({id: song.id, title: enc_title, duration: duration, source: "youtube", thumbnail: "https://img.youtube.com/vi/" + song.id + "/mqdefault.jpg"});
}
}
if(more) Search.addVideos(next_ids);