mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed issue with not all songs being added on export to YouTube
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
margin-top:100px;
|
||||
}
|
||||
|
||||
.current_number{
|
||||
color: black;
|
||||
}
|
||||
|
||||
#descriptions_cont, #thumbnails_cont{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
4
public/dist/embed.min.js
vendored
4
public/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/main.min.js
vendored
8
public/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -703,48 +703,17 @@ var List = {
|
||||
success: function(response){
|
||||
var number_added = 0;
|
||||
var playlist_id = response.id;
|
||||
$.each(full_playlist, function(i, data){
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: request_url,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + access_token_data_youtube.access_token,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
'snippet': {
|
||||
'playlistId': playlist_id,
|
||||
'resourceId': {
|
||||
'kind': 'youtube#video',
|
||||
'videoId': data.id
|
||||
}
|
||||
}
|
||||
}),
|
||||
error: function(code){
|
||||
if(number_added == full_playlist.length - 1){
|
||||
Helper.log("All videoes added!");
|
||||
Helper.log("url: https://www.youtube.com/playlist?list=" + playlist_id);
|
||||
$(".exported-list").append("<h5>Exported list</h5>");
|
||||
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
||||
$("#playlist_loader_export").addClass("hide");
|
||||
}
|
||||
number_added += 1;
|
||||
},
|
||||
success: function(response){
|
||||
Helper.log("Added video: " + data.id + " to playlist id " + playlist_id);
|
||||
if(number_added == full_playlist.length - 1){
|
||||
Helper.log("All videoes added!");
|
||||
Helper.log("url: https://www.youtube.com/playlist?list=" + playlist_id);
|
||||
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
||||
$("#playlist_loader_export").addClass("hide");
|
||||
//$(".youtube_export_button").removeClass("hide");
|
||||
}
|
||||
number_added += 1;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";
|
||||
List.addToYoutubePlaylist(playlist_id, full_playlist, number_added, request_url)
|
||||
/*$.each(full_playlist, function(i, data){
|
||||
//console.log(data.id);
|
||||
//var id = data.id;
|
||||
setTimeout(function(){
|
||||
console.log(id);
|
||||
List.addToYoutubePlaylist(playlist_id, id, number_added, request_url)
|
||||
number_added = number_added + 1;
|
||||
}, 500);
|
||||
});*/
|
||||
},
|
||||
error: function(response){
|
||||
Helper.log(response);
|
||||
@@ -752,6 +721,46 @@ var List = {
|
||||
});
|
||||
},
|
||||
|
||||
addToYoutubePlaylist: function(playlist_id, full_playlist, num, request_url){
|
||||
var _data = JSON.stringify({
|
||||
'snippet': {
|
||||
'playlistId': playlist_id,
|
||||
'resourceId': {
|
||||
'kind': 'youtube#video',
|
||||
'videoId': full_playlist[num].id
|
||||
}
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: request_url,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + access_token_data_youtube.access_token,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: _data,
|
||||
success: function(response){
|
||||
//console.log(response);
|
||||
Helper.log("Added video: " + full_playlist[num].id + " to playlist id " + playlist_id);
|
||||
if(num == full_playlist.length - 1){
|
||||
Helper.log("All videoes added!");
|
||||
Helper.log("url: https://www.youtube.com/playlist?list=" + playlist_id);
|
||||
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
||||
$("#playlist_loader_export").addClass("hide");
|
||||
$(".current_number").addClass("hide");
|
||||
//$(".youtube_export_button").removeClass("hide");
|
||||
} else {
|
||||
//setTimeout(function(){
|
||||
$(".current_number").removeClass("hide");
|
||||
$(".current_number").text((num + 1) + " of " + (full_playlist.length));
|
||||
List.addToYoutubePlaylist(playlist_id, full_playlist, num + 1, request_url)
|
||||
//}, 50);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
importOldList: function(chan){
|
||||
var ids="";
|
||||
var num=0;
|
||||
@@ -849,7 +858,7 @@ var List = {
|
||||
}else if(!list){
|
||||
//song.find(".card-duration").remove();
|
||||
song.find(".vote-text").text("");
|
||||
song.find(".card-duration").text(_song_info.duration);
|
||||
song.find(".card-duration").text(Helper.pad(_song_info.duration[0]) + ":" + Helper.pad(_song_info.duration[1]));
|
||||
|
||||
attr = ".add-suggested";
|
||||
if(user)
|
||||
|
||||
@@ -1079,14 +1079,14 @@ $("#clickme").click(function(){
|
||||
$(document).on("click", "#listExport", function(e){
|
||||
e.preventDefault();
|
||||
Helper.log(full_playlist);
|
||||
$("#playlist_loader_export").removeClass("hide");
|
||||
$(".youtube_export_button").addClass("hide");
|
||||
if(!youtube_authenticated){
|
||||
var nonce = randomString(29);
|
||||
window.callback = function(data) {
|
||||
access_token_data_youtube = data;
|
||||
if(access_token_data_youtube.state == nonce){
|
||||
youtube_authenticated = true;
|
||||
$("#playlist_loader_export").removeClass("hide");
|
||||
$(".youtube_export_button").addClass("hide");
|
||||
setTimeout(function(){
|
||||
youtube_authenticated = false;
|
||||
access_token_data_youtube = {};
|
||||
|
||||
@@ -12,13 +12,13 @@ var Suggestions = {
|
||||
},
|
||||
|
||||
createSuggested: function(params){
|
||||
var secs = params.duration;
|
||||
var duration = Helper.secondsToOther(params.duration);
|
||||
var video_id = params.id;
|
||||
var video_title = params.title;
|
||||
var minutes = Math.floor(secs / 60);
|
||||
/*var minutes = Math.floor(secs / 60);
|
||||
var seconds = secs - minutes * 60;
|
||||
|
||||
duration = Helper.pad(minutes) + ":" + Helper.pad(seconds);
|
||||
duration = Helper.pad(minutes) + ":" + Helper.pad(seconds);*/
|
||||
|
||||
var song = List.generateSong({id: video_id, title: video_title, length: secs, duration: duration}, false, false, false, true);
|
||||
$("#user-suggest-html").append(song);
|
||||
@@ -50,13 +50,13 @@ var Suggestions = {
|
||||
$.each(response.items, function(i,song)
|
||||
{
|
||||
var duration = song.contentDetails.duration;
|
||||
var secs = Search.durationToSeconds(duration);
|
||||
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
||||
var video_id = song.id;
|
||||
var video_title = song.snippet.title;
|
||||
|
||||
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
||||
//duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
||||
|
||||
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: secs, duration: duration}, false, false, false));
|
||||
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, duration: duration}, false, false, false));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -412,54 +412,59 @@
|
||||
</li>
|
||||
<li class="exported-list-container white-bg hide">
|
||||
<div class="valign playlist_loader_padding">
|
||||
<div id="playlist_loader_export" class="preloader-wrapper small active hide">
|
||||
<div class="spinner-layer spinner-blue">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s2">
|
||||
<div id="playlist_loader_export" class="preloader-wrapper small active hide">
|
||||
<div class="spinner-layer spinner-blue">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="spinner-layer spinner-red">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spinner-layer spinner-red">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="spinner-layer spinner-yellow">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spinner-layer spinner-yellow">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="spinner-layer spinner-green">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
<div class="spinner-layer spinner-green">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="current_number hide col s8 offset-s2">0/0</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user