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:
parent
743476b2d0
commit
b3f5626c1e
2 changed files with 36 additions and 19 deletions
|
@ -12,23 +12,20 @@ $obj->msg = array();
|
||||||
|
|
||||||
if (!User::canUpload()) {
|
if (!User::canUpload()) {
|
||||||
$obj->msg[] = __("Permission denied");
|
$obj->msg[] = __("Permission denied");
|
||||||
} else if (!empty($_POST['videoLink'])) {
|
} else if (!empty($_POST['itemsToSave'])) {
|
||||||
|
|
||||||
if (!is_array($_POST['videoLink'])) {
|
foreach ($_POST['itemsToSave'] as $value) {
|
||||||
$_POST['videoLink'] = array($_POST['videoLink']);
|
//$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value));
|
||||||
}
|
//$infoObj = json_decode($info);
|
||||||
foreach ($_POST['videoLink'] as $value) {
|
|
||||||
$info = url_get_contents($config->getEncoderURL() . "getLinkInfo/" . base64_encode($value));
|
|
||||||
$infoObj = json_decode($info);
|
|
||||||
$filename = uniqid("_YPTuniqid_", true);
|
$filename = uniqid("_YPTuniqid_", true);
|
||||||
$videos = new Video();
|
$videos = new Video();
|
||||||
$videos->setFilename($filename);
|
$videos->setFilename($filename);
|
||||||
$videos->setTitle($infoObj->title);
|
$videos->setTitle($value['title']);
|
||||||
$videos->setClean_title($infoObj->title);
|
$videos->setClean_title($value['title']);
|
||||||
$videos->setDuration($infoObj->duration);
|
$videos->setDuration($value['duration']);
|
||||||
$videos->setDescription($infoObj->description);
|
$videos->setDescription($value['description']);
|
||||||
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", base64_decode($infoObj->thumbs64));
|
file_put_contents($global['systemRootPath'] . "videos/{$filename}.jpg", $value['thumbs']);
|
||||||
$videos->setVideoLink($value);
|
$videos->setVideoLink($value['link']);
|
||||||
$videos->setType('embed');
|
$videos->setType('embed');
|
||||||
|
|
||||||
$videos->setStatus('a');
|
$videos->setStatus('a');
|
||||||
|
|
|
@ -140,7 +140,6 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
$("input:checkbox[name=videoCheckbox]").each(function () {
|
$("input:checkbox[name=videoCheckbox]").each(function () {
|
||||||
videoLink.push($(this).val());
|
videoLink.push($(this).val());
|
||||||
});
|
});
|
||||||
console.log(videoLink);
|
|
||||||
saveIt(videoLink);
|
saveIt(videoLink);
|
||||||
});
|
});
|
||||||
$('#getSelected').click(function () {
|
$('#getSelected').click(function () {
|
||||||
|
@ -148,16 +147,37 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
$("input:checkbox[name=videoCheckbox]:checked").each(function () {
|
$("input:checkbox[name=videoCheckbox]:checked").each(function () {
|
||||||
videoLink.push($(this).val());
|
videoLink.push($(this).val());
|
||||||
});
|
});
|
||||||
console.log(videoLink);
|
|
||||||
saveIt(videoLink);
|
saveIt(videoLink);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function saveIt(videoLink) {
|
function saveIt(videoLink) {
|
||||||
modal.showPleaseWait();
|
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({
|
$.ajax({
|
||||||
url: '<?php echo $global['webSiteRootURL']; ?>plugin/BulkEmbed/save.json.php',
|
url: '<?php echo $global['webSiteRootURL']; ?>plugin/BulkEmbed/save.json.php',
|
||||||
data: {"videoLink": videoLink},
|
data: {"itemsToSave": itemsToSave},
|
||||||
type: 'post',
|
type: 'post',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (!response.error) {
|
if (!response.error) {
|
||||||
|
@ -168,6 +188,7 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
modal.hidePleaseWait();
|
modal.hidePleaseWait();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
|
@ -191,10 +212,9 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
var prevPageToken = data.prevPageToken;
|
var prevPageToken = data.prevPageToken;
|
||||||
|
|
||||||
// Log data
|
// Log data
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
|
|
||||||
$.each(data.items, function (i, item) {
|
$.each(data.items, function (i, item) {
|
||||||
|
|
||||||
// Get Output
|
// Get Output
|
||||||
var output = getOutput(item);
|
var output = getOutput(item);
|
||||||
|
|
||||||
|
@ -316,7 +336,7 @@ $obj = YouPHPTubePlugin::getObjectData("BulkEmbed");
|
||||||
'<img src="' + thumb + '">' +
|
'<img src="' + thumb + '">' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="list-right">' +
|
'<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>' +
|
'<small>By <span class="cTitle">' + channelTitle + '</span> on ' + videoDate + '</small>' +
|
||||||
'<p>' + description + '</p>' +
|
'<p>' + description + '</p>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue