mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Add playlist now v3
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
var old_input="";
|
var old_input="";
|
||||||
var timer = 0;
|
var timer = 0;
|
||||||
|
var api_key = "***REMOVED***";
|
||||||
var result_html = $("#temp-results").html();
|
var result_html = $("#temp-results").html();
|
||||||
$( "#results" ).empty();
|
$( "#results" ).empty();
|
||||||
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/
|
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/
|
||||||
@@ -61,17 +62,19 @@ $(document).ready(function()
|
|||||||
pId = search_input.split("list=");
|
pId = search_input.split("list=");
|
||||||
if(pId.length > 1)
|
if(pId.length > 1)
|
||||||
{
|
{
|
||||||
pListUrl = "http://gdata.youtube.com/feeds/api/playlists/"+pId[1]+"/?format=5&max-results=50&v=2&alt=jsonc";
|
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=40&key="+api_key+"&playlistId="+pId[1];
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: pListUrl,
|
url: playlist_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
$.each(response.data.items, function(i,data)
|
var ids="";
|
||||||
|
$.each(response.items, function(i,data)
|
||||||
{
|
{
|
||||||
submit(data.video.id, data.video.title, data.video.duration);
|
ids+=data.contentDetails.videoId+",";
|
||||||
});
|
});
|
||||||
|
addVideos(ids);
|
||||||
document.getElementById("search").value = "";
|
document.getElementById("search").value = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -135,11 +138,11 @@ function search(search_input){
|
|||||||
var keyword= encodeURIComponent(window.search_input);
|
var keyword= encodeURIComponent(window.search_input);
|
||||||
|
|
||||||
//response= x
|
//response= x
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key=***REMOVED***&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";
|
||||||
yt_url+="&q="+keyword;
|
yt_url+="&q="+keyword;
|
||||||
if(music)yt_url+="&videoCategoryId=10";
|
if(music)yt_url+="&videoCategoryId=10";
|
||||||
|
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -212,6 +215,28 @@ function submitAndClose(id,title,duration){
|
|||||||
$(".main").removeClass("clickthrough");
|
$(".main").removeClass("clickthrough");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addVideos(ids){
|
||||||
|
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
||||||
|
request_url += ids;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: request_url,
|
||||||
|
dataType:"jsonp",
|
||||||
|
success: function(response){
|
||||||
|
$.each(response.items, function(i,song)
|
||||||
|
{
|
||||||
|
var duration=durationToSeconds(song.contentDetails.duration);
|
||||||
|
if(!longsongs || secs<720){
|
||||||
|
enc_title=encodeURIComponent(song.snippet.title).replace(/'/g, "\\\'");
|
||||||
|
submit(song.id, enc_title, duration);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function submit(id,title,duration){
|
function submit(id,title,duration){
|
||||||
socket.emit("add", [id, decodeURIComponent(title), adminpass, duration]);
|
socket.emit("add", [id, decodeURIComponent(title), adminpass, duration]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user