]> OzVa Git service - utter-news/commitdiff
Added initial site
authorwill <greenwoodw50@gmail.com>
Fri, 20 Sep 2024 20:31:54 +0000 (21:31 +0100)
committerwill <greenwoodw50@gmail.com>
Fri, 20 Sep 2024 20:31:54 +0000 (21:31 +0100)
.gitignore [new file with mode: 0644]
index.php [new file with mode: 0644]
script.sh [new file with mode: 0755]
style.css [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ee88966
--- /dev/null
@@ -0,0 +1 @@
+assets/
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..054cdf8
--- /dev/null
+++ b/index.php
@@ -0,0 +1,101 @@
+<html>
+    <head>
+        <link rel="stylesheet" href="./style.css">
+        <script>
+function getTime() {
+    var now = new Date();
+    var text = (60 - now.getMinutes() - 1) + "' " + (60 - now.getSeconds()) + "\"";
+    document.getElementById("air").innerHTML = text;
+}
+setInterval(getTime, 100);
+        </script>
+    </head>
+    <body>
+        <h1>Utter news authenticated upload</h1>
+        <h2>Next airtime: <em id="air">Loading...</em></h2>
+        <h3>Welcome to the Utter News upload page.</h3>
+        <p>Here you will upload your recorded news to the playout system, automatically scheduling it.</p>
+        <h4>Guide</h4>
+        <ol>
+            <li>Record your news voice over, make sure to do this somewhere as quiet as possible. This can even be done on your phone. Don't worry about leaving long pauses, the proccessing system will remove these automatically!</li>
+            <li>Pick your intro jingle, outro jingle and bed.</li>
+            <li>Upload the file from your device or recorder.</li>
+            <li>Click submit and it's done!'</li>
+            <li>Your news will playout at the next top-of-the-hour oppertunity*.</li>
+        </ol>
+        <p><em>*Note that between 22:00 and 02:00, this will be replaced by Spaceweather.</em></p>
+        <h4>Supported file types</h4>
+        <p>.wav, .mp3, .vorbis, .ogg, .aif</p>
+        <p style="padding: 5px; color: green; border: 1.5px solid green;">
+            Note from will:<br>
+            Just waiting on some idents from Jeremy, will hopefully give some more variety in the idents that can be picked! I'll also be building in .mp3 support soon...<br>
+            Also if anything goes wrong pls let me know asap!
+        </p>
+        <form action="./index.php" method="post" enctype="multipart/form-data">
+            <fieldset>
+                <legend>Front ident</legend>
+                <input type="radio" name="frontId" id="frontId" value="assets/front_news.wav" checked="checked"/>
+                <label for="frontId">Utter news generic</label>
+            </fieldset>
+
+            <fieldset>
+                <legend>Bed</legend>
+                <input type="radio" name="bed" id="bed" value="assets/bed_news.wav" checked="checked"/>
+                <label for="bed">Utter news generic</label>
+            </fieldset>
+
+            <fieldset>
+                <legend>Back ident</legend>
+                <input type="radio" name="backId" id="backId" value="assets/back_news.wav" checked="checked"/>
+                <label for="backId">Utter news generic</label>
+            </fieldset>
+            <br><label for="file">Select a file (.wav)</label>
+            <br><input type="file" id="file" name="file"/>
+            <br><br><input type="submit" name="upload" value="upload"/>
+            <br><br><output>
+<?php
+# error_reporting(E_ALL);
+# ini_set('display_errors', 'On');
+
+if (!empty($_POST['upload'])) {
+    echo "Uploading...<br>";
+
+    $fileType = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
+    $targetFile = "assets/upload." . $fileType;
+    $uploadOk = true;
+
+    # remove the . to prevent sandbox escape
+    $frontId = str_replace(".", "", $_POST["frontId"]);
+    $bedId = str_replace(".", "", $_POST["bedId"]);
+    $backId = str_replace(".", "", $_POST["backId"]);
+
+    if($fileType != "wav" && $fileType != "mp3" && $fileType != "ogg" && $fileType != "vorbis" && $fileType != "aif") {
+        echo "<span class='utter'>Only .wav and .mp3 files are currently allowed.</span><br>";
+        $uploadOk = false;
+    }
+
+    if (move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile) and $uploadOk) {
+        echo "<span class='green'>File successfully uploaded!</span><br>Processing...<br>";
+
+        # convert to wav if not already
+        if ($fileType != "wav") {
+            exec("sox assets/upload.$fileType assets/upload.wav");
+        }
+
+        $output=null;
+        $retval=null;
+        exec("./script.sh", $output, $retval);
+        $output = var_export($output, true);
+        if ($retval == "0") {
+            echo "<span class='green'>Finished processing successfully.</span><br><br>";
+            echo "<audio controls src='assets/news.wav' />";
+        }
+    } else {
+        echo "<span class='utter'>Sorry, there was an error uploading your file.</span>";
+    }
+}
+?>
+            </output>
+        </form>
+    </body>
+</html>
diff --git a/script.sh b/script.sh
new file mode 100755 (executable)
index 0000000..ff226f8
--- /dev/null
+++ b/script.sh
@@ -0,0 +1,20 @@
+sox assets/upload.wav -c 1 -r 48k assets/temp.wav \
+norm -3 \
+silence -l 1 0.1 1% -1 2.0 1% \
+compand 0.01,1 -90,-90,-70,-70,-60,-20,0,0 -5
+
+fadein=$((48000 * 1))
+fadeout=$((48000 * 4))
+padding=$((fadein + fadeout))
+
+length=$(soxi -s assets/temp.wav)
+length=$((length + padding))
+
+sox assets/temp.wav assets/vox.wav pad "$fadein"s 0
+sox assets/bed_news.wav assets/temp.wav \
+trim 0s "$length"s \
+fade 0 -0 "$fadeout"s
+
+sox assets/front_news.wav "|sox -M assets/vox.wav assets/temp.wav -c 1 -t sox -" assets/back_news.wav assets/news.wav norm -3
+
+exit 0
diff --git a/style.css b/style.css
new file mode 100644 (file)
index 0000000..6990fa6
--- /dev/null
+++ b/style.css
@@ -0,0 +1,26 @@
+body {
+    --utter: #bd003a;
+
+    font-family: sans-serif;
+    margin: 0;
+}
+body > *:not(h1) {
+    width: max(60%, 300px);
+    margin: 0 auto;
+}
+.utter {
+    color: var(--utter);
+}
+.green {
+    color: green;
+}
+
+h1 {
+    text-align: center;
+    color: white;
+    background-color: var(--utter);
+}
+h2 {
+    text-align: center;
+    color: var(--utter);
+}