mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
parent
0d29df8c7c
commit
e916a87c0f
5 changed files with 37 additions and 10 deletions
|
@ -82,6 +82,26 @@ function getDatabaseTime()
|
||||||
return $_getDatabaseTime;
|
return $_getDatabaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a valid ISO 8601 date to MySQL format (Y-m-d H:i:s).
|
||||||
|
* If the date is invalid, return an empty string.
|
||||||
|
*
|
||||||
|
* @param string $date
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function convertToMySQLDate(string $date): string
|
||||||
|
{
|
||||||
|
// Try to parse the date with DateTime
|
||||||
|
try {
|
||||||
|
$dateTime = new DateTime($date);
|
||||||
|
// Return the date in MySQL format
|
||||||
|
return $dateTime->format('Y-m-d H:i:s');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// If the date is invalid, return an empty string
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getMySQLDate()
|
function getMySQLDate()
|
||||||
{
|
{
|
||||||
|
|
|
@ -230,7 +230,7 @@ if (!class_exists('Video')) {
|
||||||
|
|
||||||
public function setCreated($created): void
|
public function setCreated($created): void
|
||||||
{
|
{
|
||||||
$this->created = $created;
|
$this->created = convertToMySQLDate($created);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id_company(): int
|
function getUsers_id_company(): int
|
||||||
|
|
|
@ -37,6 +37,7 @@ class BulkEmbed extends PluginAbstract {
|
||||||
|
|
||||||
$obj->API_KEY = "AIzaSyCIqxE86BawU33Um2HEGtX4PcrUWeCh_6o";
|
$obj->API_KEY = "AIzaSyCIqxE86BawU33Um2HEGtX4PcrUWeCh_6o";
|
||||||
$obj->onlyAdminCanBulkEmbed = true;
|
$obj->onlyAdminCanBulkEmbed = true;
|
||||||
|
$obj->useOriginalYoutubeDate = true;
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ function ISO8601ToSeconds($ISO8601)
|
||||||
$minutes = intval(@$minutes);
|
$minutes = intval(@$minutes);
|
||||||
$seconds = intval(@$seconds);
|
$seconds = intval(@$seconds);
|
||||||
|
|
||||||
$toltalSeconds = ($hours * 60 * 60) + ($minutes * 60) + $seconds;
|
$totalSeconds = ($hours * 60 * 60) + ($minutes * 60) + $seconds;
|
||||||
|
|
||||||
return $toltalSeconds;
|
return $totalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ISO8601ToDuration($ISO8601)
|
function ISO8601ToDuration($ISO8601)
|
||||||
|
@ -48,7 +48,6 @@ $obj->error = true;
|
||||||
$obj->msg = array();
|
$obj->msg = array();
|
||||||
$obj->playListId = 0;
|
$obj->playListId = 0;
|
||||||
|
|
||||||
|
|
||||||
$objo = AVideoPlugin::getObjectDataIfEnabled('BulkEmbed');
|
$objo = AVideoPlugin::getObjectDataIfEnabled('BulkEmbed');
|
||||||
if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
|
if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
|
||||||
$obj->msg[] = __("Permission denied");
|
$obj->msg[] = __("Permission denied");
|
||||||
|
@ -82,6 +81,12 @@ if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
|
||||||
$videos->setDescription($value['description']);
|
$videos->setDescription($value['description']);
|
||||||
$videos->setClean_title($value['title']);
|
$videos->setClean_title($value['title']);
|
||||||
$videos->setDuration(ISO8601ToDuration($value['duration']));
|
$videos->setDuration(ISO8601ToDuration($value['duration']));
|
||||||
|
|
||||||
|
// Set the original video date if available in the form data
|
||||||
|
if (!empty($value['date']) && $objo->useOriginalYoutubeDate) {
|
||||||
|
$videos->setCreated($value['date']); // Set the original creation date of the video
|
||||||
|
}
|
||||||
|
|
||||||
$poster = Video::getPathToFile("{$paths['filename']}.jpg");
|
$poster = Video::getPathToFile("{$paths['filename']}.jpg");
|
||||||
$thumbs = $value['thumbs'];
|
$thumbs = $value['thumbs'];
|
||||||
if (!empty($thumbs)) {
|
if (!empty($thumbs)) {
|
||||||
|
@ -89,7 +94,7 @@ if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
|
||||||
if (!empty($contentThumbs)) {
|
if (!empty($contentThumbs)) {
|
||||||
make_path($poster);
|
make_path($poster);
|
||||||
$bytes = file_put_contents($poster, $contentThumbs);
|
$bytes = file_put_contents($poster, $contentThumbs);
|
||||||
_error_log("thumbs={$thumbs} poster=$poster bytes=$bytes strlen=".strlen($contentThumbs));
|
_error_log("thumbs={$thumbs} poster=$poster bytes=$bytes strlen=" . strlen($contentThumbs));
|
||||||
} else {
|
} else {
|
||||||
_error_log("ERROR thumbs={$thumbs} poster=$poster");
|
_error_log("ERROR thumbs={$thumbs} poster=$poster");
|
||||||
}
|
}
|
||||||
|
@ -119,7 +124,7 @@ if (empty($objo) || ($objo->onlyAdminCanBulkEmbed && !User::isAdmin())) {
|
||||||
|
|
||||||
AVideoPlugin::saveVideosAddNew($_POST, $resp);
|
AVideoPlugin::saveVideosAddNew($_POST, $resp);
|
||||||
|
|
||||||
$obj->msg[] = Video::getVideoLight($resp);
|
$obj->msg[] = array('video'=>Video::getVideoLight($resp), 'value'=>$value, 'videos_id'=>$resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
|
|
|
@ -165,8 +165,9 @@ $_page = new Page(array('Search'));
|
||||||
item.title = data.items[0].snippet.title;
|
item.title = data.items[0].snippet.title;
|
||||||
item.description = data.items[0].snippet.description;
|
item.description = data.items[0].snippet.description;
|
||||||
item.duration = data.items[0].contentDetails.duration;
|
item.duration = data.items[0].contentDetails.duration;
|
||||||
console.log(data.items[0].snippet);
|
|
||||||
item.thumbs = data.items[0].snippet.thumbnails.high.url;
|
item.thumbs = data.items[0].snippet.thumbnails.high.url;
|
||||||
|
item.date = data.items[0].snippet.publishedAt;
|
||||||
|
console.log(data.items[0].snippet, item);
|
||||||
itemsToSave.push(item);
|
itemsToSave.push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -180,9 +181,9 @@ $_page = new Page(array('Search'));
|
||||||
type: 'post',
|
type: 'post',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (!response.error) {
|
if (!response.error) {
|
||||||
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your videos have been saved!"); ?>", "success");
|
avideoAlertSuccess(__("Your videos have been saved!"));
|
||||||
} else {
|
} else {
|
||||||
avideoAlert("<?php echo __("Sorry!"); ?>", response.msg.join("<br>"), "error");
|
avideoAlertError(response.msg.join("<br>"));
|
||||||
}
|
}
|
||||||
modal.hidePleaseWait();
|
modal.hidePleaseWait();
|
||||||
}
|
}
|
||||||
|
@ -417,7 +418,7 @@ $_page = new Page(array('Search'));
|
||||||
'<img src="' + thumb + '">' +
|
'<img src="' + thumb + '">' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="list-right">' +
|
'<div class="list-right">' +
|
||||||
'<h3><input type="checkbox" value="' + 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