mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Updates
This commit is contained in:
parent
f9b92661e6
commit
296dc7df94
5 changed files with 138 additions and 27 deletions
|
@ -71,6 +71,7 @@ if (!class_exists('Video')) {
|
||||||
'a' => 'Active',
|
'a' => 'Active',
|
||||||
'k' => 'Active and Encoding',
|
'k' => 'Active and Encoding',
|
||||||
'i' => 'Inactive',
|
'i' => 'Inactive',
|
||||||
|
'h' => 'Scheduled Release Date',
|
||||||
'e' => 'Encoding',
|
'e' => 'Encoding',
|
||||||
'x' => 'Encoding Error',
|
'x' => 'Encoding Error',
|
||||||
'd' => 'Downloading',
|
'd' => 'Downloading',
|
||||||
|
@ -85,6 +86,7 @@ if (!class_exists('Video')) {
|
||||||
'a' => '<i class=\'fas fa-eye\'></i>',
|
'a' => '<i class=\'fas fa-eye\'></i>',
|
||||||
'k' => '<i class=\'fas fa-cog\'></i>',
|
'k' => '<i class=\'fas fa-cog\'></i>',
|
||||||
'i' => '<i class=\'fas fa-eye-slash\'></i>',
|
'i' => '<i class=\'fas fa-eye-slash\'></i>',
|
||||||
|
'h' => '<i class=\'fas fa-clock\'></i>',
|
||||||
'e' => '<i class=\'fas fa-cog\'></i>',
|
'e' => '<i class=\'fas fa-cog\'></i>',
|
||||||
'x' => '<i class=\'fas fa-exclamation-triangle\'></i>',
|
'x' => '<i class=\'fas fa-exclamation-triangle\'></i>',
|
||||||
'd' => '<i class=\'fas fa-download\'></i>',
|
'd' => '<i class=\'fas fa-download\'></i>',
|
||||||
|
@ -98,6 +100,7 @@ if (!class_exists('Video')) {
|
||||||
public static $statusActive = 'a';
|
public static $statusActive = 'a';
|
||||||
public static $statusActiveAndEncoding = 'k';
|
public static $statusActiveAndEncoding = 'k';
|
||||||
public static $statusInactive = 'i';
|
public static $statusInactive = 'i';
|
||||||
|
public static $statusScheduledReleaseDate = 'h';
|
||||||
public static $statusEncoding = 'e';
|
public static $statusEncoding = 'e';
|
||||||
public static $statusEncodingError = 'x';
|
public static $statusEncodingError = 'x';
|
||||||
public static $statusDownloading = 'd';
|
public static $statusDownloading = 'd';
|
||||||
|
@ -701,6 +704,11 @@ if (!class_exists('Video')) {
|
||||||
if (!empty($_REQUEST['overrideStatus'])) {
|
if (!empty($_REQUEST['overrideStatus'])) {
|
||||||
return $this->setStatus($_REQUEST['overrideStatus']);
|
return $this->setStatus($_REQUEST['overrideStatus']);
|
||||||
} else { // encoder did not provide a status
|
} else { // encoder did not provide a status
|
||||||
|
AVideoPlugin::loadPlugin('Scheduler');
|
||||||
|
$row = Scheduler::isActiveFromVideosId($this->id);
|
||||||
|
if(!empty($row)){ // there is a schedule to activate the video
|
||||||
|
return $this->setStatus(Video::$statusScheduledReleaseDate);
|
||||||
|
}else{
|
||||||
if (!empty($_REQUEST['keepEncoding'])) {
|
if (!empty($_REQUEST['keepEncoding'])) {
|
||||||
return $this->setStatus(Video::$statusActiveAndEncoding);
|
return $this->setStatus(Video::$statusActiveAndEncoding);
|
||||||
} else {
|
} else {
|
||||||
|
@ -712,6 +720,8 @@ if (!class_exists('Video')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->setStatus($default);
|
return $this->setStatus($default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5798,6 +5808,7 @@ $statusThatShowTheCompleteMenu = array(
|
||||||
$statusSearchFilter = array(
|
$statusSearchFilter = array(
|
||||||
Video::$statusActive,
|
Video::$statusActive,
|
||||||
Video::$statusInactive,
|
Video::$statusInactive,
|
||||||
|
Video::$statusScheduledReleaseDate,
|
||||||
Video::$statusEncoding,
|
Video::$statusEncoding,
|
||||||
Video::$statusTranfering,
|
Video::$statusTranfering,
|
||||||
Video::$statusUnlisted,
|
Video::$statusUnlisted,
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Scheduler_commands extends ObjectYPT {
|
||||||
protected $id, $callbackURL, $parameters, $date_to_execute, $executed_in,
|
protected $id, $callbackURL, $parameters, $date_to_execute, $executed_in,
|
||||||
$status, $callbackResponse, $timezone,
|
$status, $callbackResponse, $timezone,
|
||||||
$repeat_minute, $repeat_hour, $repeat_day_of_month, $repeat_month,
|
$repeat_minute, $repeat_hour, $repeat_day_of_month, $repeat_month,
|
||||||
$repeat_day_of_week, $type;
|
$repeat_day_of_week, $type, $videos;
|
||||||
|
|
||||||
static function getSearchFieldsNames() {
|
static function getSearchFieldsNames() {
|
||||||
return array('callbackURL', 'parameters');
|
return array('callbackURL', 'parameters');
|
||||||
|
@ -22,6 +22,34 @@ class Scheduler_commands extends ObjectYPT {
|
||||||
return 'scheduler_commands';
|
return 'scheduler_commands';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function isActiveFromVideosId($videos_id){
|
||||||
|
$row = self::getFromVideosId($videos_id);
|
||||||
|
|
||||||
|
if(!empty($row) && $row['status'] == self::$statusActive ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getFromVideosId($videos_id){
|
||||||
|
global $global;
|
||||||
|
$videos_id = intval($videos_id);
|
||||||
|
if(empty($videos_id)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id = ? LIMIT 1";
|
||||||
|
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||||
|
$res = sqlDAL::readSql($sql, "i", [$videos_id], true);
|
||||||
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
|
sqlDAL::close($res);
|
||||||
|
if ($res) {
|
||||||
|
$row = $data;
|
||||||
|
} else {
|
||||||
|
$row = false;
|
||||||
|
}
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getTimesNow() {
|
public static function getTimesNow() {
|
||||||
$minute = intval(date('i'));
|
$minute = intval(date('i'));
|
||||||
$hour = intval(date('H'));
|
$hour = intval(date('H'));
|
||||||
|
@ -177,6 +205,14 @@ class Scheduler_commands extends ObjectYPT {
|
||||||
$this->timezone = $timezone;
|
$this->timezone = $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getVideos() {
|
||||||
|
return $this->videos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setVideos($videos): void {
|
||||||
|
$this->videos = $videos;
|
||||||
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if (empty($this->date_to_execute)) {
|
if (empty($this->date_to_execute)) {
|
||||||
$this->date_to_execute = 'NULL';
|
$this->date_to_execute = 'NULL';
|
||||||
|
@ -208,6 +244,9 @@ class Scheduler_commands extends ObjectYPT {
|
||||||
if (empty($this->callbackURL)) {
|
if (empty($this->callbackURL)) {
|
||||||
$this->callbackURL = '';
|
$this->callbackURL = '';
|
||||||
}
|
}
|
||||||
|
if (empty($this->videos_id)) {
|
||||||
|
$this->videos_id = 'NULL';
|
||||||
|
}
|
||||||
|
|
||||||
$this->_setTimeZone(date_default_timezone_get());
|
$this->_setTimeZone(date_default_timezone_get());
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Scheduler extends PluginAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion() {
|
||||||
return "3.0";
|
return "4.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateScript() {
|
public function updateScript() {
|
||||||
|
@ -85,6 +85,15 @@ class Scheduler extends PluginAbstract {
|
||||||
$_executeSchelude = array();
|
$_executeSchelude = array();
|
||||||
}
|
}
|
||||||
$e = new Scheduler_commands($scheduler_commands_id);
|
$e = new Scheduler_commands($scheduler_commands_id);
|
||||||
|
|
||||||
|
$videos_id = $e->getCallbackURL();
|
||||||
|
if(!empty($videos_id)){ // make it active
|
||||||
|
$video = new Video('', '', $videos_id);
|
||||||
|
$status = $video->setStatus(Video::$statusActive);
|
||||||
|
AVideoPlugin::onNewVideo($videos_id);
|
||||||
|
return $e->setExecuted($videos_id);
|
||||||
|
}
|
||||||
|
|
||||||
$callBackURL = $e->getCallbackURL();
|
$callBackURL = $e->getCallbackURL();
|
||||||
$callBackURL = str_replace('{webSiteRootURL}', $global['webSiteRootURL'], $callBackURL);
|
$callBackURL = str_replace('{webSiteRootURL}', $global['webSiteRootURL'], $callBackURL);
|
||||||
if (!isValidURL($callBackURL)) {
|
if (!isValidURL($callBackURL)) {
|
||||||
|
@ -108,6 +117,42 @@ class Scheduler extends PluginAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function isActiveFromVideosId($videos_id){
|
||||||
|
return Scheduler_commands::isActiveFromVideosId($videos_id);;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function addVideoToRelease($date_to_execute, $videos_id) {
|
||||||
|
_error_log("Scheduler::addVideoToRelease [$date_to_execute] [$videos_id]");
|
||||||
|
if (empty($date_to_execute)) {
|
||||||
|
_error_log("Scheduler::addVideoToRelease ERROR date_to_execute is empty");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$date_to_execute_time = _strtotime($date_to_execute);
|
||||||
|
|
||||||
|
if ($date_to_execute_time <= time()) {
|
||||||
|
_error_log("Scheduler::addVideoToRelease ERROR date_to_execute must be greater than now [{$date_to_execute}] " . date('Y/m/d H:i:s', $date_to_execute_time) . ' ' . date('Y/m/d H:i:s'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($videos_id)) {
|
||||||
|
_error_log("Scheduler::addVideoToRelease ERROR videos_id is empty");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = 0;
|
||||||
|
$row = Scheduler_commands::getFromVideosId($videos_id);
|
||||||
|
if(!empty($row)){
|
||||||
|
$id = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$e = new Scheduler_commands($id);
|
||||||
|
$e->setDate_to_execute($date_to_execute);
|
||||||
|
$e->setVideos_id($videos_id);
|
||||||
|
|
||||||
|
return $e->save();
|
||||||
|
}
|
||||||
|
|
||||||
static public function add($date_to_execute, $callbackURL, $parameters = '', $type = '') {
|
static public function add($date_to_execute, $callbackURL, $parameters = '', $type = '') {
|
||||||
_error_log("Scheduler::add [$date_to_execute] [$callbackURL]");
|
_error_log("Scheduler::add [$date_to_execute] [$callbackURL]");
|
||||||
if (empty($date_to_execute)) {
|
if (empty($date_to_execute)) {
|
||||||
|
|
|
@ -13,7 +13,13 @@ CREATE TABLE IF NOT EXISTS `scheduler_commands` (
|
||||||
`repeat_hour` INT NULL,
|
`repeat_hour` INT NULL,
|
||||||
`repeat_day_of_month` INT NULL,
|
`repeat_day_of_month` INT NULL,
|
||||||
`repeat_month` INT NULL,
|
`repeat_month` INT NULL,
|
||||||
`repeat_day_of_week` INT NULL,
|
`day_of_week` INT NULL,
|
||||||
`type` VARCHAR(45) NULL,
|
`videos_id` INT(11) NULL,
|
||||||
PRIMARY KEY (`id`))
|
PRIMARY KEY (`id`),
|
||||||
|
INDEX `fk_scheduler_commands_videos1_idx` (`videos_id` ASC) VISIBLE,
|
||||||
|
CONSTRAINT `fk_scheduler_commands_videos1`
|
||||||
|
FOREIGN KEY (`videos_id`)
|
||||||
|
REFERENCES `videos` (`id`)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE)
|
||||||
ENGINE = InnoDB;
|
ENGINE = InnoDB;
|
10
plugin/Scheduler/install/updateV4.0.sql
Normal file
10
plugin/Scheduler/install/updateV4.0.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
ALTER TABLE `scheduler_commands`
|
||||||
|
ADD COLUMN `videos_id` INT(11) NULL DEFAULT NULL,
|
||||||
|
ADD INDEX `fk_scheduler_commands_videos1_idx` (`videos_id` ASC);
|
||||||
|
|
||||||
|
ALTER TABLE `scheduler_commands`
|
||||||
|
ADD CONSTRAINT `fk_scheduler_commands_videos1`
|
||||||
|
FOREIGN KEY (`videos_id`)
|
||||||
|
REFERENCES `videos` (`id`)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
Loading…
Add table
Add a link
Reference in a new issue