]> OzVa Git service - utter-news/commitdiff
Fixed output to mp3 and added "currently airing"
authorwill <greenwoodw50@gmail.com>
Fri, 20 Sep 2024 21:38:34 +0000 (22:38 +0100)
committerwill <greenwoodw50@gmail.com>
Fri, 20 Sep 2024 21:48:29 +0000 (22:48 +0100)
index.php
script.sh

index 054cdf8e4330ab8ddee8a0d61a4bed6c2b02a103..f464bed055ed4c9b97c140085dcedc7c4c40e0ae 100644 (file)
--- a/index.php
+++ b/index.php
 <html>
-    <head>
-        <link rel="stylesheet" href="./style.css">
-        <script>
+       <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;
+       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>
+               </script>
+       </head>
+       <body>
+               <h1>Utter news authenticated upload</h1>
+               <h2>Next airtime: <em id="air">Loading...</em></h2>
+               <h2>Currently airing:</h2>
+               <h2><audio controls src="https://data.ozva.co.uk/broadcast.mp3"></audio></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>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>
+                       <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>";
+       echo "Uploading...<br>";
 
-    $fileType = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
-    $targetFile = "assets/upload." . $fileType;
-    $uploadOk = true;
+       $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"]);
+       # 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($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>";
+       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");
-        }
+               # 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=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>
+                       </output>
+               </form>
+       </body>
 </html>
index ff226f8ae140fd9db0c42c6e1278b73656ab8e20..8dcb700ac7dfab825f28059c410eb7a46b0af7ef 100755 (executable)
--- a/script.sh
+++ b/script.sh
@@ -15,6 +15,6 @@ 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
+sox assets/front_news.wav "|sox -M assets/vox.wav assets/temp.wav -c 1 -t sox -" assets/back_news.wav assets/news.mp3 norm -3
 
 exit 0