mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Bulk embed youtube videos
This commit is contained in:
parent
2f03468bfa
commit
0113773c12
1 changed files with 30 additions and 32 deletions
|
@ -153,42 +153,40 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
|
|
||||||
function saveIt(videoLink) {
|
function saveIt(videoLink) {
|
||||||
modal.showPleaseWait();
|
modal.showPleaseWait();
|
||||||
|
setTimeout(function () {
|
||||||
var itemsToSave = [];
|
var itemsToSave = [];
|
||||||
for (x in videoLink) {
|
for (x in videoLink) {
|
||||||
if (typeof videoLink[x] == 'function') {
|
if (typeof videoLink[x] === 'function') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: "https://www.googleapis.com/youtube/v3/videos?id=" + videoLink[x] + "&part=id,snippet,contentDetails&key=" + gapikey,
|
||||||
|
async: false,
|
||||||
|
success: function (data) {
|
||||||
|
var item = {};
|
||||||
|
item.link = "https://youtube.com/embed/" + data.items[0].id;
|
||||||
|
item.title = data.items[0].snippet.title;
|
||||||
|
item.description = data.items[0].snippet.description;
|
||||||
|
item.duration = data.items[0].contentDetails.duration;
|
||||||
|
item.thumbs = data.items[0].snippet.thumbnails.high.url;
|
||||||
|
itemsToSave.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "https://www.googleapis.com/youtube/v3/videos?id="+videoLink[x]+"&part=id,snippet,contentDetails&key="+gapikey,
|
url: '<?php echo $global['webSiteRootURL']; ?>plugin/BulkEmbed/save.json.php',
|
||||||
|
data: {"itemsToSave": itemsToSave},
|
||||||
async: false,
|
type: 'post',
|
||||||
success: function (data) {
|
success: function (response) {
|
||||||
var item = {};
|
if (!response.error) {
|
||||||
item.link = "https://youtube.com/embed/" + data.items[0].id;
|
swal("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your videos have been saved!"); ?>", "success");
|
||||||
item.title = data.items[0].snippet.title;
|
} else {
|
||||||
item.description = data.items[0].snippet.description;
|
swal("<?php echo __("Sorry!"); ?>", response.msg.join("<br>"), "error");
|
||||||
item.duration = data.items[0].contentDetails.duration;
|
}
|
||||||
item.thumbs = data.items[0].snippet.thumbnails.high.url;
|
modal.hidePleaseWait();
|
||||||
itemsToSave.push(item);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}, 500);
|
||||||
console.log(itemsToSave);
|
|
||||||
$.ajax({
|
|
||||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/BulkEmbed/save.json.php',
|
|
||||||
data: {"itemsToSave": itemsToSave},
|
|
||||||
type: 'post',
|
|
||||||
success: function (response) {
|
|
||||||
if (!response.error) {
|
|
||||||
swal("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your videos have been saved!"); ?>", "success");
|
|
||||||
} else {
|
|
||||||
swal("<?php echo __("Sorry!"); ?>", response.msg.join("<br>"), "error");
|
|
||||||
}
|
|
||||||
modal.hidePleaseWait();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue