1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Improve autoplay

This commit is contained in:
daniel 2020-01-13 17:53:40 -03:00
parent bb895db49c
commit f8bbc93392

45
plugin/DiscordNotify/DiscordNotify.php Normal file → Executable file
View file

@ -6,34 +6,32 @@ if (!isset($global['systemRootPath'])) {
}
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class DiscordNotify extends PluginAbstract
{
class DiscordNotify extends PluginAbstract {
public function getDescription()
{
public function getDescription() {
return "Send video upload notifications to discord webhook";
}
public function getName()
{
public function getName() {
return "DiscordNotify";
}
public function getUUID()
{
public function getUUID() {
return "cf145581-7d5e-4bb6-8c12-848a19j1564g";
}
public function getTags()
{
public function getTags() {
return array(
'free',
'notifications',
'webhook'
);
}
public function getPluginVersion() {
return "1.0";
}
public function getEmptyDataObject() {
global $global;
$server = parse_url($global['webSiteRootURL']);
@ -45,15 +43,15 @@ class DiscordNotify extends PluginAbstract
$obj->footer_image = "";
return $obj;
}
public function afterNewVideo($videos_id)
{
public function afterNewVideo($videos_id) {
global $global;
$o = $this->getDataObject();
$users_id = Video::getOwner($videos_id);
$user = new User($users_id);
$username = $user->getNameIdentification();
$channelName = $user->getChannelName();
$video = new Video("","",$videos_id);
$video = new Video("", "", $videos_id);
$videoName = $video->getTitle();
$images = Video::getImageFromFilename($video->getFilename());
$videoThumbs = $images->thumbsJpg;
@ -65,7 +63,7 @@ class DiscordNotify extends PluginAbstract
$bot_username = $o->bot_username;
$footer_image = $o->footer_image;
$hookObject = json_encode([
$hookObject = json_encode([
"content" => "",
"username" => $bot_username,
"avatar_url" => $avatar_url,
@ -77,20 +75,17 @@ $hookObject = json_encode([
"description" => "",
"url" => $global['webSiteRootURL'] . $channelName,
"timestamp" => "",
"color" => hexdec( "FF0000" ),
"color" => hexdec("FF0000"),
"footer" => [
"text" => $bot_username,
"icon_url" => $footer_image
],
"image" => [
"url" => $videoThumbs,
],
//"thumbnail" => [
// "url" => $userThumbnail
//],
"fields" => [
[
"name" => "Video Name",
@ -115,21 +110,21 @@ $hookObject = json_encode([
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$ch = curl_init();
$ch = curl_init();
curl_setopt_array( $ch, [
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Length" => strlen( $hookObject ),
"Length" => strlen($hookObject),
"Content-Type" => "application/json"
]
]);
]);
return curl_exec( $ch );
return curl_exec($ch);
}
}