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