1
0
Fork 0

add offline message

This commit is contained in:
Christopher Latza 2020-06-12 15:05:43 +02:00
parent 57774f78da
commit 94d2cd604c
2 changed files with 22 additions and 39 deletions

View File

@ -1,28 +0,0 @@
{
"embeds": [
{
"title": "RTMP Stream Online!",
"description": "Ein RTMP Stream ist jetzt online! Wenn du ihn dir anschauen willst, kannst du dies mit dem VLC Media Player tun.\nÖffne dazu den VLC Media Player, klicke oben links auf Medien und wähle Netzwerkstream. Dort trägst du dann folgene Adresse ein:\n\n%%adresse%%\n",
"color": 2139936,
"author": {
"name": "RTMP Noticer",
"url": "https://clatza.dev/Christopher/Discord-RTMP-Notice.git",
"icon_url": "https://files.clatza.dev/Icons/git.png"
},
"image": {
"url": "%%vorschau%%"
}
},
{
"title": "Stream wird aufgezeichnet.",
"description": "Für diesen Stream steht eine Aufzeichnung bereit.\nDu kannst dir den Stream in den nächsten 48 Stunden erneut anschauen.\nÖffne dazu den VLC Media Player, klicke auf Medien -> Netzwerkstream und gebe dort folgene URL ein.\n\n%%downloadURL%%\n",
"author": {
"name": "RTMP Noticer",
"url": "https://clatza.dev/Christopher/Discord-RTMP-Notice.git",
"icon_url": "https://files.clatza.dev/Icons/git.png"
}
}
],
"username": "RTMP Noticer",
"avatar_url": "https://files.clatza.dev/Icons/vlc.png"
}

View File

@ -25,28 +25,39 @@ while(TRUE)
copy($fileName, "tmp/rtmp/".$fileName);
unlink($fileName);
$jsonMessage = file_get_contents("message.json");
$jsonStartMessage = file_get_contents("startMessage.json");
$jsonEndMessage = file_get_contents("endMessage.json");
$jsonMessage = str_replace("%%adresse%%", $StreamURL, $jsonMessage);
$jsonMessage = str_replace("%%vorschau%%", "https://files.clatza.dev/tmp/rtmp/".$fileName, $jsonMessage);
$jsonMessage = str_replace("%%downloadURL%%", "https://files.clatza.dev/tmp/rtmp/".$videoFileName, $jsonMessage);
$jsonStartMessage = str_replace("%%adresse%%", $StreamURL, $jsonMessage);
$jsonStartMessage = str_replace("%%vorschau%%", "https://files.clatza.dev/tmp/rtmp/".$fileName, $jsonMessage);
$options = [
$startOptions = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'timeout' => 5,
'content' => $jsonMessage
'content' => $jsonStartMessage
]
];
echo "Sending info to discord...";
$result = file_get_contents($DiscordWebhook, false, stream_context_create($options));
$endOptions = [
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'timeout' => 5,
'content' => $jsonEndMessage
]
];
echo "Sending start info to discord...";
$result = file_get_contents($DiscordWebhook, false, stream_context_create($startOptions));
echo "done.\n";
echo "Start Recording...";
system("rtmpdump -r ".$StreamURL." -m 30 -o tmp/rtmp/".$videoFileName);
echo "done.";
system("rtmpdump -r ".$StreamURL." -m 15 -o /dev/null");
echo "Sending end info to discord...";
$result = file_get_contents($DiscordWebhook, false, stream_context_create($endOptions));
echo "done.\n";
}else{
echo "ERROR: Image not generated!\n";
}