1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Bulk embed youtube videos test

This commit is contained in:
daniel 2019-07-13 20:06:31 -03:00
parent 743476b2d0
commit b3f5626c1e
2 changed files with 36 additions and 19 deletions

View file

@ -12,23 +12,20 @@ $obj->msg = array();
if (!User::canUpload()) {
$obj->msg[] = __("Permission denied");
} else if (!empty($_POST['videoLink'])) {
} else if (!empty($_POST['itemsToSave'])) {
if (!is_array($_POST['videoLink'])) {
$_POST['videoLink'] = array($_POST['videoLink']);
}
foreach ($_POST['videoLink'] as $value) {
$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value));
$infoObj = json_decode($info);
foreach ($_POST['itemsToSave'] as $value) {
//$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value));
//$infoObj = json_decode($info);
$filename = uniqid("_YPTuniqid_", true);
$videos = new Video();
$videos->setFilename($filename);
$videos->setTitle($infoObj->title);
$videos->setClean_title($infoObj->title);
$videos->setDuration($infoObj->duration);
$videos->setDescription($infoObj->description);
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", base64_decode($infoObj->thumbs64));
$videos->setVideoLink($value);
$videos->setTitle($value['title']);
$videos->setClean_title($value['title']);
$videos->setDuration($value['duration']);
$videos->setDescription($value['description']);
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", $value['thumbs']);
$videos->setVideoLink($value['link']);
$videos->setType('embed');
$videos->setStatus('a');

View file

@ -140,7 +140,6 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
$("input:checkbox[name=videoCheckbox]").each(function () {
videoLink.push($(this).val());
});
console.log(videoLink);
saveIt(videoLink);
});
$('#getSelected').click(function () {
@ -148,16 +147,37 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
$("input:checkbox[name=videoCheckbox]:checked").each(function () {
videoLink.push($(this).val());
});
console.log(videoLink);
saveIt(videoLink);
});
});
function saveIt(videoLink) {
modal.showPleaseWait();
var itemsToSave = [];
for (x in videoLink) {
if (typeof videoLink[x] == 'function') {
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);
}
});
}
console.log(itemsToSave);
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/BulkEmbed/save.json.php',
data: {"videoLink": videoLink},
data: {"itemsToSave": itemsToSave},
type: 'post',
success: function (response) {
if (!response.error) {
@ -168,6 +188,7 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
modal.hidePleaseWait();
}
});
}
function search() {
@ -191,10 +212,9 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
var prevPageToken = data.prevPageToken;
// Log data
console.log(data);
//console.log(data);
$.each(data.items, function (i, item) {
// Get Output
var output = getOutput(item);
@ -316,7 +336,7 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
'<img src="' + thumb + '">' +
'</div>' +
'<div class="list-right">' +
'<h3><input type="checkbox" value="https://youtube.com/embed/' + videoID + '" name="videoCheckbox"><a target="_blank" href="https://youtube.com/embed/' + videoID + '?rel=0">' + title + '</a></h3>' +
'<h3><input type="checkbox" value="' + videoID + '" name="videoCheckbox"><a target="_blank" href="https://youtube.com/embed/' + videoID + '?rel=0">' + title + '</a></h3>' +
'<small>By <span class="cTitle">' + channelTitle + '</span> on ' + videoDate + '</small>' +
'<p>' + description + '</p>' +
'</div>' +