Skip to content

A live bird collage card for your Home Assistant dashboard.

I like this so far

mcguirepr89579d3b1e26cb
diff --git a/homepage/index.php b/homepage/index.php
index 368e3da2..2abdd61c 100644
--- a/homepage/index.php
+++ b/homepage/index.php
@@ -1,106 +1,24 @@
-<meta name="viewport" content="width=device-width, initial-scale=1">
+<link rel="stylesheet" href="style.css">
<div class="banner">
-<h1>BirdNET-Pi</h1>
-<form action="" method="POST">
<?php
-if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
- $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
-} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
- $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
+echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
+if(isset($_GET['stream'])){
+ echo "<h1>BirdNET-Pi</h1><br><audio controls autoplay><source src=\"/stream\"></audio>";
+} else {
+ echo "<h1>BirdNET-Pi</h1><br><form action=\"\" method=\"GET\"><button type=\"submit\" name=\"stream\" value=\"play\">Live Audio</button></form>";
}
-
-$pages = array("Overview", "Database", "Species Stats", "History", "Tools", "Live Stream", "Extractions", "Spectrogram","Log");
-foreach($pages as $page){
- echo "<button type=\"submit\" name=\"view\" value=\"$page\">$page</button>";
-}?>
-</form>
-</div>
-
-<?php
- function httpPost($url, $data){
- $curl = curl_init($url);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($curl);
- echo $response;
- }
-if(isset($_POST['view'])){
- if($_POST['view'] == "System"){header('location:phpsysinfo/index.php');}
- if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}
- if($_POST['view'] == "Overview"){include('overview.php');}
- if($_POST['view'] == "Database"){include('viewdb.php');}
- if($_POST['view'] == "Species Stats"){include('stats.php');}
- if($_POST['view'] == "History"){include('history.php');}
- if($_POST['view'] == "Tools"){
- echo "<form action=\"\" method=\"POST\">
- <button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
- <button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
- <button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
- <button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
- </form>";
- }
- if($_POST['view'] == "Live Stream"){
- echo "<audio controls autoplay><source src=\"/stream\" type=\"audio/mpeg\"></audio>";
- }
- if($_POST['view'] == "Extractions"){include('play.php');}
- if($_POST['view'] == "Settings"){include('scripts/config.php');}
- if($_POST['view'] == "Advanced"){include('scripts/advanced.php');}
- if($_POST['view'] == "Log"){
- $url = 'http://birdnetpi.local:8080';
- header("location: $url;");
- }
- if($_POST['view'] == "Included"){
- if(isset($_POST['species']) && isset($_POST['add'])){
- $file='/home/pi/BirdNET-Pi/include_species_list.txt';
- $str=file_get_contents("$file");
- $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
- file_put_contents("$file", "$str");
- if(isset($_POST['species'])){
- foreach ($_POST['species'] as $selectedOption)
- file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
- }
- } elseif(isset($_POST['species']) && isset($_POST['del'])){
- $file = '/home/pi/BirdNET-Pi/include_species_list.txt';
- $str = file_get_contents("$file");
- $str = preg_replace('/^\h*\v+/m', '', $str);
- file_put_contents("$file", "$str");
- foreach($_POST['species'] as $selectedOption) {
- $content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt");
- $newcontent = str_replace($selectedOption, "", "$content");
- file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent");
- }
- $file = '/home/pi/BirdNET-Pi/include_species_list.txt';
- $str = file_get_contents("$file");
- $str = preg_replace('/^\h*\v+/m', '', $str);
- file_put_contents("$file", "$str");
- }
- include('scripts/include_list.php');
- }
- if($_POST['view'] == "Excluded"){
- if(isset($_POST['species']) && isset($_POST['add'])){
- $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
- $str = file_get_contents("$file");
- $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
- file_put_contents("$file", "$str");
- foreach ($_POST['species'] as $selectedOption)
- file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", $selectedOption."\n", FILE_APPEND);
- } elseif (isset($_POST['species']) && isset($_POST['del'])){
- $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
- $str = file_get_contents("$file");
- $str = preg_replace('/^\h*\v+/m', '', $str);
- file_put_contents("$file", "$str");
- foreach($_POST['species'] as $selectedOption) {
- $content = file_get_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt");
- $newcontent = str_replace($selectedOption, "", "$content");
- file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", "$newcontent");
- }
- $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
- $str = file_get_contents("$file");
- $str = preg_replace('/^\h*\v+/m', '', $str);
- file_put_contents("$file", "$str");
- }
- include('scripts/exclude_list.php');
+echo "</div>";
+if(isset($_GET['log'])){
+ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
+ $logs = $config['BIRDNETLOG_URL'];
+ } elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
+ $logs = $config['BIRDNETLOG_URL'];
}
+ header("Location: $logs");
+}elseif(isset($_GET['spectrogram'])){
+ header("Location: /spectrogram.php");
+} else {
+ echo "<iframe src=\"/views.php\" width=\"100%\" height=\"85%\">";
}
-?>
diff --git a/homepage/style.css b/homepage/style.css
index e4dc2354..a1dfc628 100644
--- a/homepage/style.css
+++ b/homepage/style.css
@@ -1,96 +1,133 @@
-/* style sheet */
* {
font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
box-sizing: border-box;
}
-/* Create two equal columns that floats next to each other */
-.column2 {
+.banner {
+ height: auto;
+ text-align: center;
+}
+
+.banner h1 {
+ float: top;
+}
+
+.banner audio {
+ width: 120px;
margin-left: auto;
margin-right: auto;
- width: 75%;
- padding: 5px;
}
-/* Create two equal columns that floats next to each other */
-.column {
+/* Add a black background color to the top navigation */
+.topnav {
+ overflow: hidden;
+ background-color: rgb(119, 196, 135);
+ width:100%;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+/* Style the links inside the navigation bar */
+.topnav button {
float: left;
- width: 50%;
- padding: 5px;
+ display: block;
+ text-align: center;
+ padding: 14px 16px;
}
-/* Clear floats after the columns */
-.row:after {
- content: "";
- display: table;
- clear: both;
+/* Change the color of links on hover */
+.topnav button:hover {
+ background-color: #ddd;
+ color: black;
}
-table {
- background-color: rgb(219, 255, 235);
- margin: 0 auto;
- font-size: large;
- border-collapse: collapse;
- border-spacing: 0;
- width: 100%;
- border: 1px solid black;
+/* Add an active class to highlight the current page */
+.topnav button.active {
+ background-color: #04AA6D;
+ color: white;
}
-h1 {
- text-align: center;
- color: black;
- font-size: xx-large;
+/* Hide the link that should open and close the topnav on small screens */
+.topnav .icon {
+ display: none;
}
-h2 {
- margin-left: -150px;
- text-align: center;
- color: black;
- font-size: large;
+.topnav form {
+ float:left;
}
-h3 {
- text-align: center;
- color: black;
+iframe {
+ border: none;
+ height: 85%;
+ width: 100%;
+}
+
+body {
+ background-color: rgb(119, 196, 135);
+}
+
+table {
+ background-color: transparent;
+ margin: 0 auto;
font-size: large;
+ border-collapse: collapse;
+ border-spacing: 0;
+ width: 100%;
+/* border: 1px solid black;*/
}
td {
background-color: rgb(219, 255, 235);
font-weight: lighter;
- border: 1px solid black;
- padding: 10px;
+ border: 2px solid black;
text-align: center;
}
th {
- background-color: rgb(219, 255, 235);
font-weight: bold;
- border: 1px solid black;
- padding: 10px;
+ height: auto;
text-align: center;
}
-@media screen and (max-width: 600px) {
- h2 {
- margin-left: 0;
- text-align: center;
- color: black;
- font-size: large;
- }
-
- .column {
- width: 100%;
- }
- /* Create two equal columns that floats next to each other */
- .column2 {
- float: center;
- width: 100%;
- padding: 0px;
- }
+audio {
+ width: 100%;
+}
+button {
+ font-size: large;
+ background-color: transparent;
+ border: none;
+ color: black;
+ cursor: pointer;
+}
+.spectrogrambutton, .logbutton, .navbuttons {
+ float: left;
}
+
body::-webkit-scrollbar {
display:none
+}
+
+@media screen and (max-width: 1000px) {
+ .topnav button {display: none;}
+ .topnav form {float: none;}
+ /*.topnav button:not(:first-child) {display: none;}*/
+ .topnav button.icon {
+ display: block;
+ width: 100%;
+ margin-left: auto;
+ margin-right: auto;
+ }
+}
+
+@media screen and (max-width: 1000px) {
+ .topnav.responsive {position: relative;}
+ .topnav.responsive button {
+ float: left;
+ display: block;
+ text-align: center;
+ }
+}
diff --git a/homepage/views.php b/homepage/views.php
new file mode 100644
index 00000000..1c564a80
--- /dev/null
+++ b/homepage/views.php
@@ -0,0 +1,109 @@
+<link rel="stylesheet" href="style.css">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<div class="topnav" id="myTopnav">
+<form action="" method="POST" id="views">
+ <button type="submit" name="view" value="Overview" id="views">Overview</button>
+ <button type="submit" name="view" value="Today's Detections" id="views">Today's Detections</button>
+ <button type="submit" name="view" value="Species Stats" id="views">Species Stats</button>
+ <button type="submit" name="view" value="Daily Charts" id="views">Daily Charts</button>
+ <button type="submit" name="view" value="Tools" id="views">Tools</button>
+ <button type="submit" name="view" value="Recordings" id="views">Recordings</button>
+</form>
+<form action="index.php" method="GET" id="log">
+ <button type="submit" name="log" value="log" id="log">View Log</button>
+</form>
+<form action="index.php" method="GET" id="spectrogram">
+ <button type="submit" name="spectrogram" value="view" id="spectrogram">Spectrogram</button>
+</form>
+<button href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
+</div>
+
+<?php
+if(isset($_POST['view'])){
+ if($_POST['view'] == "System"){header('location:phpsysinfo/index.php');}
+ if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}
+ if($_POST['view'] == "Overview"){include('overview.php');}
+ if($_POST['view'] == "Today's Detections"){include('viewdb.php');}
+ if($_POST['view'] == "Species Stats"){include('stats.php');}
+ if($_POST['view'] == "Daily Charts"){include('history.php');}
+ if($_POST['view'] == "Tools"){
+ echo "<form action=\"\" method=\"POST\">
+ <button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
+ <button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
+ <button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
+ <button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
+ </form>";
+ }
+ if($_POST['view'] == "Recordings"){include('play.php');}
+ if($_POST['view'] == "Settings"){include('scripts/config.php');}
+ if($_POST['view'] == "Advanced"){include('scripts/advanced.php');}
+ if($_POST['view'] == "Log"){
+ $url = 'http://birdnetpi.local:8080';
+ header("location: $url;");
+ }
+ if($_POST['view'] == "Included"){
+ if(isset($_POST['species']) && isset($_POST['add'])){
+ $file = '/home/pi/BirdNET-Pi/include_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
+ file_put_contents("$file", "$str");
+ if(isset($_POST['species'])){
+ foreach ($_POST['species'] as $selectedOption)
+ file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
+ }
+ } elseif(isset($_POST['species']) && isset($_POST['del'])){
+ $file = '/home/pi/BirdNET-Pi/include_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace('/^\h*\v+/m', '', $str);
+ file_put_contents("$file", "$str");
+ foreach($_POST['species'] as $selectedOption) {
+ $content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt");
+ $newcontent = str_replace($selectedOption, "", "$content");
+ file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent");
+ }
+ $file = '/home/pi/BirdNET-Pi/include_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace('/^\h*\v+/m', '', $str);
+ file_put_contents("$file", "$str");
+ }
+ include('scripts/include_list.php');
+ }
+ if($_POST['view'] == "Excluded"){
+ if(isset($_POST['species']) && isset($_POST['add'])){
+ $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str);
+ file_put_contents("$file", "$str");
+ foreach ($_POST['species'] as $selectedOption)
+ file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", $selectedOption."\n", FILE_APPEND);
+ } elseif (isset($_POST['species']) && isset($_POST['del'])){
+ $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace('/^\h*\v+/m', '', $str);
+ file_put_contents("$file", "$str");
+ foreach($_POST['species'] as $selectedOption) {
+ $content = file_get_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt");
+ $newcontent = str_replace($selectedOption, "", "$content");
+ file_put_contents("/home/pi/BirdNET-Pi/exclude_species_list.txt", "$newcontent");
+ }
+ $file = '/home/pi/BirdNET-Pi/exclude_species_list.txt';
+ $str = file_get_contents("$file");
+ $str = preg_replace('/^\h*\v+/m', '', $str);
+ file_put_contents("$file", "$str");
+ }
+ include('scripts/exclude_list.php');
+ }
+}else{
+ include('overview.php');}
+?>
+<script>
+function myFunction() {
+ var x = document.getElementById("myTopnav");
+ if (x.className === "topnav") {
+ x.className += " responsive";
+ } else {
+ x.className = "topnav";
+ }
+}
+</script>
+
diff --git a/scripts/filemanager/filemanager.php b/scripts/filemanager/filemanager.php
index 1db4bb8c..934270d7 100644
--- a/scripts/filemanager/filemanager.php
+++ b/scripts/filemanager/filemanager.php
@@ -3344,7 +3344,7 @@ function fm_show_nav_path($path)
<nav class="navbar navbar-expand-lg <?php echo $getTheme; ?> mb-4 main-nav <?php echo $isStickyNavBar ?>">
<a class="navbar-brand" href="../../">BirdNET-Pi Homepage </a>
<a class="navbar-brand" href="../"><?php echo lng('Tools'); ?></a>
- <a class="navbar-brand" href="http://birdnetpi.local:8888" target="_"><?php echo lng('WebTerminal'); ?></a>
+ <a class="navbar-brand" href="https://webterminal.pmcgui.xyz" target="_"><?php echo lng('WebTerminal'); ?></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
diff --git a/scripts/get_image.sh b/scripts/get_image.sh
index 132df458..83ed84de 100755
--- a/scripts/get_image.sh
+++ b/scripts/get_image.sh
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# testing getting images dynamically
-first_call=$(lynx -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image")
-lynx -dump -listonly \
+set -x
+first_call=$(lynx -accept-all-cookies -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image")
+lynx -dump -listonly -accept-all-cookies\
$(echo "$first_call" \
| sed '11q;d' \
| awk '{print $2}' ) \
diff --git a/scripts/index.html b/scripts/index.html
index cfafa779..681b6ce3 100644
--- a/scripts/index.html
+++ b/scripts/index.html
@@ -74,7 +74,7 @@ a {
</div>
<div class="column second">
<<<<<<< Updated upstream
- <form action="http://birdnetpi.local:8080" target="top">
+ <form action="https://birdnetlog.pmcgui.xyz" target="top">
=======
<form action="http://192.168.0.100:8888" target="top">
>>>>>>> Stashed changes
diff --git a/scripts/overview.php b/scripts/overview.php
index e67161be..85604724 100644
--- a/scripts/overview.php
+++ b/scripts/overview.php
@@ -44,6 +44,7 @@ if($statement4 == False) {
$result4 = $statement4->execute();
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
+$sciname = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
$comname = preg_replace('/\'/', '', $comname);
$filename = "/By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];
@@ -79,7 +80,7 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
<tr>
<td><?php echo $totalcount['COUNT(*)'];?></td>
<form action="" method="POST">
- <td><input type="hidden" name="view" value="Extractions"><button type="submit" name="date" value="<?php echo date('Y-m-d');?>"><?php echo $todaycount['COUNT(*)'];?></button></td>
+ <td><input type="hidden" name="view" value="Recordings"><button type="submit" name="date" value="<?php echo date('Y-m-d');?>"><?php echo $todaycount['COUNT(*)'];?></button></td>
</form>
<td><?php echo $hourcount['COUNT(*)'];?></td>
<form action="" method="POST">
@@ -100,7 +101,7 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
</tr>
<tr>
<td><?php echo $mostrecent['Date']."<br>".$mostrecent['Time'];?></td>
- <td><a href="https://wikipedia.org/wiki/<?php echo $scilink;?>" target="top"/><?php echo $mostrecent['Sci_Name'];?></a></td>
+ <td><a href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="_blank"/><?php echo $mostrecent['Sci_Name'];?></a></td>
<form action="" method="POST">
<td>
<input type="hidden" name="view" value="Species Stats">
diff --git a/scripts/play.php b/scripts/play.php
index 10239b9a..e0ef825a 100644
--- a/scripts/play.php
+++ b/scripts/play.php
@@ -65,7 +65,7 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
<tr>
<form action="" method="POST">
<td>
- <input type="hidden" name="view" value="Extractions">
+ <input type="hidden" name="view" value="Recordings">
<?php
if($view == "bydate"){
$date = $results['Date'];
diff --git a/scripts/server.py b/scripts/server.py
index b3cab1af..6d0b129e 100755
--- a/scripts/server.py
+++ b/scripts/server.py
@@ -367,44 +367,45 @@ def handle_client(conn, addr):
print(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) + ';' + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' + str(args.sensitivity) +';' + str(args.overlap) + Com_Name.replace(" ", "_") + '-' + str(score) + '-' + str(current_date) + '-birdnet-' + str(current_time) + audiofmt + '\n')
if birdweather_id != "99999":
+ try:
- if soundscape_uploaded is False:
- # POST soundscape to server
- soundscape_url = "https://app.birdweather.com/api/v1/stations/" + birdweather_id + "/soundscapes" + "?timestamp=" + current_iso8601
-
- with open(args.i, 'rb') as f:
- wav_data = f.read()
- response = requests.post(url=soundscape_url, data=wav_data, headers={'Content-Type': 'application/octet-stream'})
- print("Soundscape POST Response Status - ", response.status_code)
- sdata = response.json()
- soundscape_id = sdata['soundscape']['id']
- soundscape_uploaded = True
-
- # POST detection to server
- detection_url = "https://app.birdweather.com/api/v1/stations/" + birdweather_id + "/detections"
- start_time = d.split(';')[0]
- end_time = d.split(';')[1]
- post_begin = "{ "
- now_p_start = now + datetime.timedelta(seconds=float(start_time))
- current_iso8601 = now_p_start.astimezone(get_localzone()).isoformat()
- post_timestamp = "\"timestamp\": \"" + current_iso8601 + "\","
- post_lat = "\"lat\": " + str(args.lat) + ","
- post_lon = "\"lon\": " + str(args.lon) + ","
- post_soundscape_id = "\"soundscapeId\": " + str(soundscape_id) + ","
- post_soundscape_start_time = "\"soundscapeStartTime\": " + start_time + ","
- post_soundscape_end_time = "\"soundscapeEndTime\": " + end_time + ","
- post_commonName = "\"commonName\": \"" + entry[0].split('_')[1] + "\","
- post_scientificName = "\"scientificName\": \"" + entry[0].split('_')[0] + "\","
- post_algorithm = "\"algorithm\": " + "\"alpha\"" + ","
- post_confidence = "\"confidence\": " + str(entry[1])
- post_end = " }"
-
- post_json = post_begin + post_timestamp + post_lat + post_lon + post_soundscape_id + post_soundscape_start_time + post_soundscape_end_time + post_commonName + post_scientificName + post_algorithm + post_confidence + post_end
- print(post_json)
- response = requests.post(detection_url, json=json.loads(post_json))
- print("Detection POST Response Status - ", response.status_code)
-
-
+ if soundscape_uploaded is False:
+ # POST soundscape to server
+ soundscape_url = "https://app.birdweather.com/api/v1/stations/" + birdweather_id + "/soundscapes" + "?timestamp=" + current_iso8601
+
+ with open(args.i, 'rb') as f:
+ wav_data = f.read()
+ response = requests.post(url=soundscape_url, data=wav_data, headers={'Content-Type': 'application/octet-stream'})
+ print("Soundscape POST Response Status - ", response.status_code)
+ sdata = response.json()
+ soundscape_id = sdata['soundscape']['id']
+ soundscape_uploaded = True
+
+ # POST detection to server
+ detection_url = "https://app.birdweather.com/api/v1/stations/" + birdweather_id + "/detections"
+ start_time = d.split(';')[0]
+ end_time = d.split(';')[1]
+ post_begin = "{ "
+ now_p_start = now + datetime.timedelta(seconds=float(start_time))
+ current_iso8601 = now_p_start.astimezone(get_localzone()).isoformat()
+ post_timestamp = "\"timestamp\": \"" + current_iso8601 + "\","
+ post_lat = "\"lat\": " + str(args.lat) + ","
+ post_lon = "\"lon\": " + str(args.lon) + ","
+ post_soundscape_id = "\"soundscapeId\": " + str(soundscape_id) + ","
+ post_soundscape_start_time = "\"soundscapeStartTime\": " + start_time + ","
+ post_soundscape_end_time = "\"soundscapeEndTime\": " + end_time + ","
+ post_commonName = "\"commonName\": \"" + entry[0].split('_')[1] + "\","
+ post_scientificName = "\"scientificName\": \"" + entry[0].split('_')[0] + "\","
+ post_algorithm = "\"algorithm\": " + "\"alpha\"" + ","
+ post_confidence = "\"confidence\": " + str(entry[1])
+ post_end = " }"
+
+ post_json = post_begin + post_timestamp + post_lat + post_lon + post_soundscape_id + post_soundscape_start_time + post_soundscape_end_time + post_commonName + post_scientificName + post_algorithm + post_confidence + post_end
+ print(post_json)
+ response = requests.post(detection_url, json=json.loads(post_json))
+ print("Detection POST Response Status - ", response.status_code)
+ except:
+ print("Cannot POST right now")
conn.send(myReturn.encode(FORMAT))
#time.sleep(3)
diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php
index cc324bf8..31b177e9 100644
--- a/scripts/spectrogram.php
+++ b/scripts/spectrogram.php
@@ -1,4 +1,11 @@
<?php
+if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
+} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
+ $config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
+}
+$refresh = $config['RECORDING_LENGTH'];
$time = time();
echo "<img src=\"/spectrogram.png?nocache=$time\">";
+header("Refresh: $refresh;");
?>
diff --git a/scripts/stats.php b/scripts/stats.php
index 98989b65..bb16c45a 100644
--- a/scripts/stats.php
+++ b/scripts/stats.php
@@ -98,26 +98,31 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){
$dbsciname = preg_replace('/ /', '_', $sciname);
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$comname = preg_replace('/\'/', '', $comname);
+ $linkname = preg_replace('/_/', '+', $dbsciname);
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
- $imagelink = shell_exec("/home/pi/BirdNET-Pi/scripts/get_image.sh $dbsciname");
- $imagecitation = shell_exec("/home/pi/BirdNET-Pi/scripts/get_citation.sh $dbsciname");
echo str_pad("<tr>
<td><a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/>$sciname</a></td>
<td>$count</td>
<td>$maxconf</td>
- <td>$date $time <audio controls><source src=\"$filename\"></audio></td>
+ <td>$date $time<br><audio controls><source src=\"$filename\"></audio></td>
<td><a href=\"https://allaboutbirds.org/guide/$comname\" target=\"top\"/>All About Birds</a></td>
</tr>
- </table>", '4096');
- ob_flush();
- flush();
- echo str_pad("<img class=\"center\" src=\"$imagelink\">
- <pre>$imagecitation</pre></td>
- </div>
-</div>
-</div>", '4096');
+ </table>
+ <p>Loading Images from https://commons.wikimedia.org/w/index.php?search=$linkname&title=Special:MediaSearch&go=Go&type=image</p>", '6096');
+
ob_flush();
flush();
+ $imagelink = "https://commons.wikimedia.org/w/index.php?search=$linkname&title=Special:MediaSearch&go=Go&type=image";
+ $homepage = file_get_contents($imagelink);
+ preg_match_all("{<img\\s*(.*?)src=('.*?'|\".*?\"|[^\\s]+)(.*?)\\s*/?>}ims", $homepage, $matches, PREG_SET_ORDER);
+ foreach ($matches as $val) {
+ $pos = strpos($val[2],"/");
+ $link = substr($val[2],1,-1);
+ if($pos == 1)
+ echo "http://domain.com" . $link;
+ elseif(strpos($link, "upload") == true)
+ echo "<img src=\"$link\">";
+ }
}}
?>
diff --git a/scripts/viewdb.php b/scripts/viewdb.php
index 05e5126e..6dcfcb44 100644
--- a/scripts/viewdb.php
+++ b/scripts/viewdb.php
@@ -82,7 +82,7 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
<tr>
<td><?php echo $totalcount['COUNT(*)'];?></td>
<form action="" method="POST">
- <td><input type="hidden" name="view" value="Extractions"><button type="submit" name="date" value="<?php echo date('Y-m-d');?>"><?php echo $todaycount['COUNT(*)'];?></button></td>
+ <td><input type="hidden" name="view" value="Recordings"><button type="submit" name="date" value="<?php echo date('Y-m-d');?>"><?php echo $todaycount['COUNT(*)'];?></button></td>
</form>
<td><?php echo $hourcount['COUNT(*)'];?></td>
<form action="" method="POST">