|
|
@ -1,5 +1,5 @@ |
|
|
|
var MPDartist, MPDsong, MPDfile, MPDCurr; |
|
|
|
var MPDartist, MPDsong, MPDfile, MPDCurr, YouURL; |
|
|
|
MPDartist = MPDsong = MPDfile = MPDCurr = 'empty'; |
|
|
|
MPDartist = MPDsong = MPDfile = MPDCurr = YouURL = 'empty'; |
|
|
|
|
|
|
|
|
|
|
|
function show() |
|
|
|
function show() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -32,10 +32,11 @@ function show() |
|
|
|
MPDsong = MPDfile.replace(/^.*\s-/,'').replace(/^\s*/,'').replace(/\s*$/,''); |
|
|
|
MPDsong = MPDfile.replace(/^.*\s-/,'').replace(/^\s*/,'').replace(/\s*$/,''); |
|
|
|
getArtistURL(MPDartist); |
|
|
|
getArtistURL(MPDartist); |
|
|
|
$("#trackname span").text(MPDartist+" - "+MPDsong); |
|
|
|
$("#trackname span").text(MPDartist+" - "+MPDsong); |
|
|
|
|
|
|
|
getYouTubeRequest(MPDfile); |
|
|
|
} else if (MPDCurr != MPDfile) { |
|
|
|
} else if (MPDCurr != MPDfile) { |
|
|
|
getArtistURL(MPDartist); |
|
|
|
getArtistURL(MPDartist); |
|
|
|
$("#trackname span").text(MPDartist+" - "+MPDsong); |
|
|
|
$("#trackname span").text(MPDartist+" - "+MPDsong); |
|
|
|
|
|
|
|
getYouTubeRequest(MPDfile); |
|
|
|
} |
|
|
|
} |
|
|
|
MPDCurr = MPDfile; |
|
|
|
MPDCurr = MPDfile; |
|
|
|
}); |
|
|
|
}); |
|
|
@ -66,3 +67,24 @@ function getSongURL(MPDartist, MPDsong) |
|
|
|
document.querySelector('form[name="songURL"]').setAttribute('action', MPDsong); |
|
|
|
document.querySelector('form[name="songURL"]').setAttribute('action', MPDsong); |
|
|
|
console.log(MPDsong) |
|
|
|
console.log(MPDsong) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Функция для поиска по YouTube
|
|
|
|
|
|
|
|
function getYouTubeRequest(MPDfile) { |
|
|
|
|
|
|
|
var url = 'https://www.googleapis.com/youtube/v3/search'; |
|
|
|
|
|
|
|
var params = { |
|
|
|
|
|
|
|
// part: 'id',
|
|
|
|
|
|
|
|
part: 'snippet', |
|
|
|
|
|
|
|
key: 'AIzaSyCqebfGlbbqoM0oEbbBsK87IZhlS3_Urcg', |
|
|
|
|
|
|
|
q: MPDfile |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.getJSON(url, params, showResults); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showResults(results) { |
|
|
|
|
|
|
|
var entries = results.items; |
|
|
|
|
|
|
|
thumb = entries[0].snippet.thumbnails.medium.url; |
|
|
|
|
|
|
|
YouURL = entries[0].id.videoId; |
|
|
|
|
|
|
|
document.querySelector('img[name="YouTubeThumb"]').setAttribute('src', thumb); |
|
|
|
|
|
|
|
document.querySelector('a[name="YouTubeURL"]').setAttribute('href', "https://www.youtube.com/watch?v="+YouURL); |
|
|
|
|
|
|
|
} |
|
|
|