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

update DiscordNotify plugin

This commit is contained in:
Puyodead1 2021-09-13 13:46:47 +00:00
parent f8dc15fbb5
commit ff535a0a3d

View file

@ -43,6 +43,7 @@ class DiscordNotify extends PluginAbstract {
} }
public function afterNewVideo($videos_id) { public function afterNewVideo($videos_id) {
_error_log("DiscordNotify:afterNewVideo start");
global $global; global $global;
$o = $this->getDataObject(); $o = $this->getDataObject();
$users_id = Video::getOwner($videos_id); $users_id = Video::getOwner($videos_id);
@ -60,6 +61,7 @@ class DiscordNotify extends PluginAbstract {
$avatar_url = $o->avatar_url; $avatar_url = $o->avatar_url;
$bot_username = $o->bot_username; $bot_username = $o->bot_username;
$footer_image = $o->footer_image; $footer_image = $o->footer_image;
_error_log("DiscordNotify:afterNewVideo: {$url}");
$hookObject = json_encode([ $hookObject = json_encode([
"content" => "", "content" => "",
@ -70,9 +72,8 @@ class DiscordNotify extends PluginAbstract {
[ [
"title" => $username . " just uploaded a video", "title" => $username . " just uploaded a video",
"type" => "rich", "type" => "rich",
"description" => "",
"url" => $global['webSiteRootURL'] . $channelName, "url" => $global['webSiteRootURL'] . $channelName,
"timestamp" => "", "timestamp" => gmdate('Y-m-d\TH:i:s', time()),
"color" => hexdec("FF0000"), "color" => hexdec("FF0000"),
"footer" => [ "footer" => [
"text" => $bot_username, "text" => $bot_username,
@ -81,9 +82,6 @@ class DiscordNotify extends PluginAbstract {
"image" => [ "image" => [
"url" => $videoThumbs, "url" => $videoThumbs,
], ],
//"thumbnail" => [
// "url" => $userThumbnail
//],
"fields" => [ "fields" => [
[ [
"name" => "Video Name", "name" => "Video Name",
@ -110,18 +108,14 @@ class DiscordNotify extends PluginAbstract {
] ]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init(); $c = curl_init($url);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt_array($ch, [ curl_setopt($c, CURLOPT_POST, true);
CURLOPT_URL => $url, curl_setopt($c, CURLOPT_POSTFIELDS, $hookObject);
CURLOPT_POST => true, curl_setopt($c, CURLOPT_HTTPHEADER, array(
CURLOPT_POSTFIELDS => $hookObject, 'Content-Type: application/json',
CURLOPT_HTTPHEADER => [ ));
"Content-Type: application/json" curl_exec($c);
] curl_close($c);
]);
return curl_exec($ch);
} }
} }