commit b0830f23ed5e2da34e755af99452dcc171a5d57e Author: Ben Harris Date: Mon Nov 19 21:09:20 2018 +0000 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73ca285 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*/ +!webhook/ +webhook/*.log +webhook/ffmpeg.pid diff --git a/djindex.php b/djindex.php new file mode 100644 index 0000000..813dda9 --- /dev/null +++ b/djindex.php @@ -0,0 +1,34 @@ + + + + + <?=$dj?>'s tilderadio archives + + + + + + + +
+

's archive

+

< back

+
+ +
+ +

+
+
+ + +
+ + + diff --git a/favicon.png b/favicon.png new file mode 100644 index 0000000..035d63e Binary files /dev/null and b/favicon.png differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..523db9c --- /dev/null +++ b/index.php @@ -0,0 +1,31 @@ + + + + tilderadio archives + + + + + + + +
+

tilderadio archive

+

back to tilderadio.org - listen now

+
+ +
+ +

+
+
+ + +
+ + + diff --git a/webhook/index.php b/webhook/index.php new file mode 100644 index 0000000..0d378a6 --- /dev/null +++ b/webhook/index.php @@ -0,0 +1,34 @@ +live->is_live) { + // start recording + $streamer = $json->live->streamer_name; + + $current_pid = intval(file_get_contents("ffmpeg.pid")); + // posix_kill with 0 signal tells you if the process is running + if ($current_pid != "" && posix_kill($current_pid, 0)) die(); + + $timestamp = date("Y-m-d\TH:i:s"); + if (!is_dir(__DIR__."/../$streamer")) { + mkdir(__DIR__."/../$streamer"); + copy(__DIR__."/../djindex.php", __DIR__."/../$streamer/index.php"); + } + + $standard_stream = "https://radio.tildeverse.org/radio/8000/radio.ogg"; + $testing_stream = "https://radio.tildeverse.org/radio/8010/radio.mp3"; + $cmd = "/usr/bin/ffmpeg -i $standard_stream ../$streamer/tilderadio-$timestamp.mp3 >out.log 2>&1 & echo $!"; + $pid = exec($cmd); + + echo $pid; + file_put_contents("ffmpeg.pid", $pid); +} else { + // stop recording + $pid = file_get_contents("ffmpeg.pid"); + if ($pid != "" && posix_kill(intval($pid), 0)) { + posix_kill(intval($pid), 2); + file_put_contents("ffmpeg.pid", ""); + } +} +