mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed spotify import even better
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
static/images/thumbnails/
|
static/images/thumbnails/
|
||||||
node_modules/
|
node_modules/
|
||||||
scripts/
|
scripts/
|
||||||
|
.DS_Store
|
||||||
|
|||||||
2
static/dist/embed.min.js
vendored
2
static/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
6
static/dist/main.min.js
vendored
6
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -305,6 +305,7 @@ var List = {
|
|||||||
|
|
||||||
getIndexOfSong: function(id)
|
getIndexOfSong: function(id)
|
||||||
{
|
{
|
||||||
|
console.log(full_playlist);
|
||||||
indexes = $.map(full_playlist, function(obj, index) {
|
indexes = $.map(full_playlist, function(obj, index) {
|
||||||
if(obj.id == id) {
|
if(obj.id == id) {
|
||||||
return index;
|
return index;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
var Search = {
|
var Search = {
|
||||||
|
|
||||||
|
submitArray: [],
|
||||||
|
submitArrayExpected: null,
|
||||||
|
|
||||||
showSearch: function(){
|
showSearch: function(){
|
||||||
$("#search-wrapper").toggleClass("hide");
|
$("#search-wrapper").toggleClass("hide");
|
||||||
if(Helper.mobilecheck())
|
if(Helper.mobilecheck())
|
||||||
@@ -125,7 +128,7 @@ var Search = {
|
|||||||
|
|
||||||
backgroundSearch: function(title, artist, length, totalNumber, current){
|
backgroundSearch: function(title, artist, length, totalNumber, current){
|
||||||
var keyword= encodeURIComponent(title + " " + artist);
|
var keyword= encodeURIComponent(title + " " + artist);
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=5";
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10";
|
||||||
yt_url+="&q="+keyword;
|
yt_url+="&q="+keyword;
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
artist = artist.split(" ");
|
artist = artist.split(" ");
|
||||||
@@ -137,28 +140,25 @@ var Search = {
|
|||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
//console.log(response);
|
//console.log(response);
|
||||||
if(response.items.length > 0) {
|
if(response.items.length === 0){
|
||||||
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
|
if(localStorage.debug === "true") {
|
||||||
|
console.log("------------------------------");
|
||||||
|
console.log("NO MATCH FOR:");
|
||||||
|
console.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
|
console.log("Spotify length: " + length);
|
||||||
|
console.log("------------------------------");
|
||||||
|
}
|
||||||
|
var not_added_song = $("<div>" + not_import_html + "</div>");
|
||||||
|
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
||||||
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
|
$(".not-imported").removeClass("hide");
|
||||||
|
} else if(response.items.length > 0) {
|
||||||
$.each(response.items, function(i,data)
|
$.each(response.items, function(i,data)
|
||||||
{
|
{
|
||||||
var acceptable_track = true;
|
|
||||||
//console.log(data.snippet.title.toLowerCase().indexOf("cover"));
|
|
||||||
//$.each(artist, function(i, data_artist){
|
|
||||||
if(data.snippet.title.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
|
||||||
(data.snippet.channelTitle.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
|
||||||
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)){
|
|
||||||
acceptable_track = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//});
|
|
||||||
|
|
||||||
if(data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
|
||||||
acceptable_track && title.toLowerCase().indexOf("cover") == -1 &&
|
|
||||||
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
|
||||||
title.toLowerCase().indexOf("remix") == -1) ||
|
|
||||||
(data.snippet.title.toLowerCase().indexOf("remix") != -1 &&
|
|
||||||
title.toLowerCase().indexOf("remix") != -1))) {
|
|
||||||
vid_url += data.id.videoId+",";
|
vid_url += data.id.videoId+",";
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -174,7 +174,16 @@ var Search = {
|
|||||||
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
||||||
var not_matched = false;
|
var not_matched = false;
|
||||||
$.each(temptitle, function(i, data_title){
|
$.each(temptitle, function(i, data_title){
|
||||||
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1)
|
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
||||||
|
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
|
title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
|
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
||||||
|
title.toLowerCase().indexOf("remix") == -1) ||
|
||||||
|
(data.snippet.title.toLowerCase().indexOf("remix") != -1 &&
|
||||||
|
title.toLowerCase().indexOf("remix") != -1) || !(data.snippet.title.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
||||||
|
(data.snippet.channelTitle.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
||||||
|
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)))
|
||||||
|
))
|
||||||
not_matched = true;
|
not_matched = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -194,11 +203,13 @@ var Search = {
|
|||||||
console.log("Spotify title: " + title + " " + artist.join(" "));
|
console.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
console.log("Spotify length: " + length);
|
console.log("Spotify length: " + length);
|
||||||
console.log("------------------------------");*/
|
console.log("------------------------------");*/
|
||||||
Search.submit(data.id,data.snippet.title, duration, true, current, totalNumber);
|
//Search.submit(data.id,data.snippet.title, duration, true, current, totalNumber);
|
||||||
|
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!matched){
|
if(!matched){
|
||||||
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
if(localStorage.debug === "true") {
|
if(localStorage.debug === "true") {
|
||||||
console.log("------------------------------");
|
console.log("------------------------------");
|
||||||
console.log("NO MATCH FOR:");
|
console.log("NO MATCH FOR:");
|
||||||
@@ -227,6 +238,24 @@ var Search = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
readySubmit: function(found, obj){
|
||||||
|
if(Search.submitArrayExpected === null){
|
||||||
|
Search.submitArrayExpected = obj.totalLength;
|
||||||
|
}
|
||||||
|
if(found){
|
||||||
|
Search.submitArray.push(obj);
|
||||||
|
} else {
|
||||||
|
Search.submitArrayExpected -= 1;
|
||||||
|
}
|
||||||
|
if((Search.submitArray.length - 1) == Search.submitArrayExpected) {
|
||||||
|
$.each(Search.submitArray, function(i, data){
|
||||||
|
Search.submit(data.id, data.title, data.duration, true, i, Search.submitArray.length - 1);
|
||||||
|
});
|
||||||
|
Search.submitArray = [];
|
||||||
|
Search.submitArrayExpected = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
submitAndClose: function(id,title,duration){
|
submitAndClose: function(id,title,duration){
|
||||||
Search.submit(id,title, duration, false, 0, 1);
|
Search.submit(id,title, duration, false, 0, 1);
|
||||||
$("#results").html('');
|
$("#results").html('');
|
||||||
|
|||||||
Reference in New Issue
Block a user