mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
API update
This commit is contained in:
parent
af98a6f3f4
commit
b514beaaab
5 changed files with 94 additions and 25 deletions
|
@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$installationVersion = "9.1";
|
$installationVersion = "9.2";
|
||||||
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
|
@ -378,6 +378,79 @@ class API extends PluginAbstract {
|
||||||
return new ApiObject("API Secret is not valid");
|
return new ApiObject("API Secret is not valid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type $parameters
|
||||||
|
* 'videos_id' the video id that will be deleted
|
||||||
|
* ['APISecret' if passed will not require user and pass]
|
||||||
|
* ['user' usename of the user that will like the video]
|
||||||
|
* ['pass' password of the user that will like the video]
|
||||||
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
||||||
|
* @return \ApiObject
|
||||||
|
*/
|
||||||
|
public function get_api_video_delete($parameters) {
|
||||||
|
global $global;
|
||||||
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
$dataObj = $this->getDataObject();
|
||||||
|
if (!empty($parameters['videos_id'])) {
|
||||||
|
if (!User::canUpload()) {
|
||||||
|
return new ApiObject("Access denied");
|
||||||
|
}
|
||||||
|
if (!empty($_GET['APISecret']) && $dataObj->APISecret !== $_GET['APISecret']) {
|
||||||
|
return new ApiObject("Secret does not match");
|
||||||
|
}
|
||||||
|
$obj = new Video("", "", $parameters['videos_id']);
|
||||||
|
if (!$obj->userCanManageVideo()) {
|
||||||
|
return new ApiObject("User cannot manage the video");
|
||||||
|
}
|
||||||
|
$id = $obj->delete();
|
||||||
|
return new ApiObject("", !$id, $id);
|
||||||
|
} else {
|
||||||
|
return new ApiObject("Video ID is required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type $parameters
|
||||||
|
* 'videos_id' the video id that will be deleted
|
||||||
|
* 'title' the video title
|
||||||
|
* 'status' the video status
|
||||||
|
* ['APISecret' if passed will not require user and pass]
|
||||||
|
* ['user' usename of the user that will like the video]
|
||||||
|
* ['pass' password of the user that will like the video]
|
||||||
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
||||||
|
* @return \ApiObject
|
||||||
|
*/
|
||||||
|
public function get_api_video_save($parameters) {
|
||||||
|
global $global;
|
||||||
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
$dataObj = $this->getDataObject();
|
||||||
|
if (!empty($parameters['videos_id'])) {
|
||||||
|
if (!User::canUpload()) {
|
||||||
|
return new ApiObject("Access denied");
|
||||||
|
}
|
||||||
|
if (!empty($_GET['APISecret']) && $dataObj->APISecret !== $_GET['APISecret']) {
|
||||||
|
return new ApiObject("Secret does not match");
|
||||||
|
}
|
||||||
|
$obj = new Video("", "", $parameters['videos_id']);
|
||||||
|
if (!$obj->userCanManageVideo()) {
|
||||||
|
return new ApiObject("User cannot manage the video");
|
||||||
|
}
|
||||||
|
if(!empty($parameters['title'])){
|
||||||
|
$obj->setTitle($parameters['title']);
|
||||||
|
}
|
||||||
|
if(!empty($parameters['status'])){
|
||||||
|
$obj->setStatus($parameters['status']);
|
||||||
|
}
|
||||||
|
$id = $obj->save();
|
||||||
|
return new ApiObject("", !$id, $id);
|
||||||
|
} else {
|
||||||
|
return new ApiObject("Video ID is required");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type $parameters
|
* @param type $parameters
|
||||||
|
|
7
plugin/CustomizeUser/customizeUser.json.php
Normal file
7
plugin/CustomizeUser/customizeUser.json.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
require_once '../../videos/configuration.php';
|
||||||
|
session_write_close();
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$obj = AVideoPlugin::getObjectData("CustomizeUser");
|
||||||
|
echo json_encode($obj);
|
||||||
|
include $global['systemRootPath'].'objects/include_end.php';
|
|
@ -28,31 +28,18 @@ $video = $liveLink->getLink();
|
||||||
|
|
||||||
if (preg_match("/\b(?:(?:https?):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $video)) {
|
if (preg_match("/\b(?:(?:https?):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $video)) {
|
||||||
$url = $config->getEncoderURL() . "getImage/" . base64_encode($video) . "/{$_GET['format']}";
|
$url = $config->getEncoderURL() . "getImage/" . base64_encode($video) . "/{$_GET['format']}";
|
||||||
if (empty($_SESSION[$url]['expire']) || $_SESSION[$url]['expire'] < time()) {
|
$name = "liveLinks_getImage_".md5($url);
|
||||||
//_error_log("LiveLink: getImage.php: " . $url);
|
$content = ObjectYPT::getCache($name, 600);
|
||||||
$content = url_get_contents($url);
|
if(empty($content)){
|
||||||
if (session_status() == PHP_SESSION_NONE) {
|
$content = url_get_contents($url, "", 2);
|
||||||
session_start();
|
if(!empty($content)){
|
||||||
|
ObjectYPT::setCache($name, $content);
|
||||||
}
|
}
|
||||||
//_error_log(" Image Expired in " . date("d/m/Y H:i:s", @$_SESSION[$url]['expire']) . " NOW is " . date("d/m/Y H:i:s"));
|
|
||||||
$_SESSION[$url] = array('content' => $content, 'expire' => strtotime("+2 min"));
|
|
||||||
//_error_log(" New Image will Expired in " . date("d/m/Y H:i:s", $_SESSION[$url]['expire']) . " NOW is " . date("d/m/Y H:i:s"));
|
|
||||||
}
|
}
|
||||||
if (!empty($_SESSION[$url]['content'])) {
|
|
||||||
ob_end_clean();
|
|
||||||
echo $_SESSION[$url]['content'];
|
|
||||||
//_error_log(" Cached Good until " . date("d/m/Y H:i:s", $_SESSION[$url]['expire']) . " NOW is " . date("d/m/Y H:i:s"));
|
|
||||||
} else {
|
|
||||||
ob_end_clean();
|
|
||||||
echo url_get_contents($filename);
|
|
||||||
//_error_log(" Get default image ");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ob_end_clean();
|
|
||||||
echo local_get_contents($filename);
|
|
||||||
//_error_log(" Invalid URL ");
|
|
||||||
}
|
}
|
||||||
$p = AVideoPlugin::loadPluginIfEnabled("Cache");
|
|
||||||
if (!empty($p)) {
|
if(!empty($content)){
|
||||||
$p->getEnd();
|
echo $content;
|
||||||
|
}else{
|
||||||
|
echo local_get_contents($filename);
|
||||||
}
|
}
|
2
updatedb/updateDb.v9.2.sql
Normal file
2
updatedb/updateDb.v9.2.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
-- new API features
|
||||||
|
UPDATE configurations SET version = '9.2', modified = now() WHERE id = 1;
|
Loading…
Add table
Add a link
Reference in a new issue