saving changes

This commit is contained in:
mcguirepr89
2022-02-24 13:27:08 -05:00
parent cf0a3436f7
commit 10090f9411
11 changed files with 87 additions and 96 deletions
+9 -9
View File
@@ -166,9 +166,9 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--include_list "${INCLUDE_LIST}"
--include_list "${INCLUDE_LIST}"
elif [ -f ${1}/${i} ] && [ ! -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
echo "analyze.py \
--i "${1}/${i}" \
@@ -187,9 +187,9 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--exclude_list "${EXCLUDE_LIST}"
--exclude_list "${EXCLUDE_LIST}"
elif [ -f ${1}/${i} ] && [ -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
echo "analyze.py \
--i "${1}/${i}" \
@@ -209,7 +209,7 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--include_list "${INCLUDE_LIST}" \
--exclude_list "${EXCLUDE_LIST}"
@@ -231,7 +231,7 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--birdweather_id "${BIRDWEATHER_ID}"
elif [ -f ${1}/${i} ] && [ -f ${INCLUDE_LIST} ] && [ ! -f ${EXCLUDE_LIST} ] && [ ! -z $BIRDWEATHER_ID ];then
@@ -253,7 +253,7 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--include_list "${INCLUDE_LIST}" \
--birdweather_id "${BIRDWEATHER_ID}"
@@ -276,7 +276,7 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--exclude_list "${EXCLUDE_LIST}" \
--birdweather_id "${BIRDWEATHER_ID}"
@@ -300,7 +300,7 @@ run_analysis() {
--lon "${LONGITUDE}" \
--week "${WEEK}" \
--overlap "${OVERLAP}" \
--sensitivity "${SENSITIVITY}" \
--sensitivity "${SENSITIVITY}" \
--min_conf "${CONFIDENCE}" \
--include_list "${INCLUDE_LIST}" \
--exclude_list "${EXCLUDE_LIST}" \
+1
View File
@@ -60,6 +60,7 @@ sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/history.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/play.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/images/favicon.ico ${EXTRACTED}
sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED}
sudo -u ${USER} cp -f $(dirname ${my_dir})/templates/phpsysinfo.ini ${HOME}/phpsysinfo/
+5 -9
View File
@@ -12,7 +12,7 @@ ini_set('display_errors',1);
<body>
<div class="row">
<div class="column first">
<form action="write_config.php" method="POST" name="normal">
<form action="" method="POST">
<?php
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
@@ -66,20 +66,16 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
<option value="labels_uk.txt">Ukrainian</option>
</select>
<br><br>
<button type="submit" name="normal" class="block"><?php
if(isset($_SESSION['success'])){
<button type="submit" name="view" value="Settings"><?php
if(isset($_POST['status'])){
echo "Success!";
unset($_SESSION['success']);
} else {
echo "Update Settings";
}
?></button>
</form>
<form action="advanced.php" class="form2">
<button type="submit" class="block">Advanced Settings</button>
</form>
<form action="index.html" class="form2">
<button type="submit" class="block">Tools</button>
<form action="" method="POST">
<button type="submit" name="view" value="Advanced">Advanced Settings</button>
</form>
</div>
</div>
+22 -14
View File
@@ -28,7 +28,7 @@ if($statement2 == False) {
$result2 = $statement2->execute();
$todaycount = $result2->fetchArray(SQLITE3_ASSOC);
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == Date(\'now\', \'localtime\') AND TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
if($statement3 == False) {
echo "Database is busy";
header("refresh: 0;");
@@ -78,9 +78,13 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
</tr>
<tr>
<td><?php echo $totalcount['COUNT(*)'];?></td>
<td><a href="/By_Date/<?php echo date('Y-m-d');?>"/><?php echo $todaycount['COUNT(*)'];?></a></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>
</form>
<td><?php echo $hourcount['COUNT(*)'];?></td>
<td><a href="/stats.php"/><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></a></td>
<form action="" method="POST">
<td><button type="submit" name="view" value="Species Stats"><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></button></td>
</form>
</tr>
</table>
</div>
@@ -88,19 +92,23 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
<table>
<tr>
<th</th>
<th>Scientific Name</th>
<th>Common Name</th>
<th>Listen</th>
<th>Confidence</th>
<th>Most Recent Detection</th>
<th>Scientific Name</th>
<th>Common Name</th>
<th>Listen</th>
<th>Confidence</th>
</tr>
<tr>
<th>Most Recent Detection</th>
<td><a href="https://wikipedia.org/wiki/<?php echo $scilink;?>" target="top"/><?php echo $mostrecent['Sci_Name'];?></a></td>
<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>
<form action="" method="POST">
<td><input type="hidden" name="view" value="Species Stats"><button type="submit" name="species" value="<?php echo $mostrecent['Com_Name'];?>"><?php echo $mostrecent['Com_Name'];?></button></td></form>
<td><?php echo $mostrecent['Date']." ".$mostrecent['Time'];?><br><audio controls><source src="<?php echo $filename;?>"></audio></td>
<td><?php echo $mostrecent['Confidence'];?></td>
<td>
<input type="hidden" name="view" value="Species Stats">
<button type="submit" name="species" value="<?php echo $mostrecent['Com_Name'];?>"><?php echo $mostrecent['Com_Name'];?></button>
</td>
</form>
<td><audio controls><source src="<?php echo $filename;?>"></audio></td>
<td><?php echo $mostrecent['Confidence'];?></td>
</tr>
</table>
</div>
@@ -108,7 +116,7 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
if (file_exists('/home/pi/BirdSongs/Extracted/Charts/'.$chart)) {
echo "<img src=\"/Charts/$chart?nocache=time()\">";
} else {
echo "<p>No Detections For Today</p>";
echo "<p>No Detections For Today</p>";
}
?>
<h2>Currently Analyzing</h2>
+27 -27
View File
@@ -10,24 +10,16 @@ if($db == False){
}
if(isset($_POST['bydate'])){
$statement = $db->prepare('SELECT DISTINCT(Date), Com_Name from detections GROUP BY Date');
$statement = $db->prepare('SELECT DISTINCT(Date), Com_Name FROM detections GROUP BY Date');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "bydate";
} elseif(isset($_POST['byspecies'])) {
$statement = $db->prepare('SELECT DISTINCT(Com_Name) from detections ORDER BY Com_Name');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "byspecies";
} elseif(isset($_POST['date'])) {
$date = $_POST['date'];
$statement = $db->prepare("SELECT DISTINCT(Com_Name) from detections WHERE Date == \"$date\" ORDER BY Com_Name");
$statement = $db->prepare("SELECT DISTINCT(Com_Name) FROM detections WHERE Date == \"$date\" ORDER BY Com_Name");
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
@@ -36,8 +28,8 @@ if(isset($_POST['bydate'])){
$view = "date";
} elseif(isset($_POST['species'])) {
$species = $_POST['species'];
$statement = $db->prepare("SELECT * from detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement3 = $db->prepare("SELECT Date, Time, Com_Name, MAX(Confidence), File_Name from detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement = $db->prepare("SELECT * FROM detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement3 = $db->prepare("SELECT Date, Time, Com_Name, MAX(Confidence), File_Name FROM detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
if($statement == False || $statement3 == False){
echo "Database is busy";
header("refresh: 0;");
@@ -45,8 +37,15 @@ if(isset($_POST['bydate'])){
$result = $statement->execute();
$result3 = $statement3->execute();
$view = "species";
} else {
$statement = $db->prepare('SELECT DISTINCT(Com_Name) FROM detections ORDER BY Com_Name');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "byspecies";
}
?>
<html>
@@ -57,7 +56,6 @@ if(isset($_POST['bydate'])){
</style>
</head>
<body>
<div class="column left">
<table>
<?php
if(!isset($_POST['species'])){
@@ -67,6 +65,7 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
<tr>
<form action="" method="POST">
<td>
<input type="hidden" name="view" value="Extractions">
<?php
if($view == "bydate"){
$date = $results['Date'];
@@ -82,23 +81,25 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
$maxconf = $results['MAX(Confidence)'];
$date = $results['Date'];
$time = $results['Time'];
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$name = $results['Com_Name'];
$comname = preg_replace('/ /', '_', $name);
$comname = preg_replace('/\'/', '', $comname);
$file = $results['File_Name'];
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
echo "<table>
<tr>
<th>$name</th>
<th>Max Confidence: $maxconf</th>
</tr>
<tr>
<td>Most confident recording: <a href=\"$filename\" target=\"footer\">$file</a></td>
<th>Most confident recording: </th>
<td><audio controls><source src=\"$filename\"></audio></td>
</tr></table>";
};};?>
</td>
</form>
</tr>
</table>
</div>
<div class="column right">
<?php
if(isset($_POST['species'])){
$name = $_POST['species'];
@@ -110,8 +111,8 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
$result2 = $statement2->execute();
echo "<table>
<tr>
<th>Date</th>
<th>Time</th>
<th>When</th>
<th>Listen</th>
<th>Scientific Name</th>
<th>Common Name</th>
<th>Confidence</th>
@@ -119,24 +120,23 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
while($results=$result2->fetchArray(SQLITE3_ASSOC))
{
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$comname = preg_replace('/\'/', '', $comname);
$date = $results['Date'];
$comlink = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
$sciname = preg_replace('/ /', '_', $results['Sci_Name']);
$sci_name = $results['Sci_Name'];
$time = $results['Time'];
$confidence = $results['Confidence'];
echo "<tr>
<td>$date</td>
<td><a href=\"$comlink\" target=\"footer\"/>$time</a></td>
<td>$date $time</td>
<td><audio controls><source src=\"$filename\"></audio></td>
<td><a href=\"https://wikipedia.org/wiki/$sciname\" target=\"top\">$sci_name</a></td>
<form action=\"/stats.php\" method=\"POST\">
<td><button type=\"submit\" name=\"species\" value=\"$name\">$name</button>
<form action=\"\" method=\"POST\">
<td><input type=\"hidden\" name=\"view\" value=\"Species Stats\"><button type=\"submit\" name=\"species\" value=\"$name\">$name</button>
</form></td>
<td>$confidence</td>
</tr>";
}echo "</table>";}?>
</div>
</div>
</body>
</html>
+1 -1
View File
@@ -23,6 +23,6 @@ sudo systemctl restart "${i}"
done
until grep 5050 <(netstat -tulpn 2>&1);do
sudo systemctl restart birdnet_server.service
sleep 30
sleep 45
done
sudo systemctl restart birdnet_analysis.service
+1
View File
@@ -349,6 +349,7 @@ def handle_client(conn, addr):
Week = str(args.week)
Sens = str(args.sensitivity)
Overlap = str(args.overlap)
Com_Name = Com_Name.replate("'", "")
File_Name = Com_Name.replace(" ", "_") + '-' + Confidence + '-' + \
Date.replace("/", "-") + '-birdnet-' + Time + audiofmt
+2 -9
View File
@@ -1,11 +1,4 @@
<?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');
}
$refreshtime = $config['RECORDING_LENGTH'];
header("refresh:$refreshtime");
$time = time();
echo "<img src=\"/spectrogram.png?nocache=$time\">";
?>
<body>
<img src='/spectrogram.png?nocache=<?php echo time();?>'>
+7 -6
View File
@@ -76,7 +76,6 @@ $filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name'];
$species = $_POST['species'];
$str = "<div class=\"column second\">
<h3>$species</h3>
<h3>Species Stats</h3>
<table>
<tr>
<th>Scientific Name</th>
@@ -96,27 +95,29 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){
$time = $results['Time'];
$name = $results['Com_Name'];
$sciname = $results['Sci_Name'];
$dbsciname = preg_replace('/ /', '_', $sciname);
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$comname = preg_replace('/\'/', '', $comname);
$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");
$str= "<tr>
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><a href=\"https://allaboutbirds.org/guide/$comname\" target=\"top\"/>All About Birds</a></td>
</tr>
</table>";
echo str_pad($str, 4096);
</table>", '4096');
ob_flush();
flush();
echo "<img class=\"center\" src=\"$imagelink\">
echo str_pad("<img class=\"center\" src=\"$imagelink\">
<pre>$imagecitation</pre></td>
</div>
</div>
</div>";
</div>", '4096');
ob_flush();
flush();
}}
?>
+12 -7
View File
@@ -3,8 +3,6 @@ ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
header("refresh: 30;");
$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
if($db == False){
echo "Database is busy";
@@ -34,7 +32,7 @@ if($statement2 == False){
$result2 = $statement2->execute();
$todaycount = $result2->fetchArray(SQLITE3_ASSOC);
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == Date(\'now\', \'localtime\') AND TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
if($statement3 == False){
echo "Database is busy";
header("refresh: 0;");
@@ -83,15 +81,20 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
</tr>
<tr>
<td><?php echo $totalcount['COUNT(*)'];?></td>
<td><a href="/By_Date/<?php echo date('Y-m-d');?>"/><?php echo $todaycount['COUNT(*)'];?></a></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>
</form>
<td><?php echo $hourcount['COUNT(*)'];?></td>
<td><a href="/stats.php"/><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></a></td>
<form action="" method="POST">
<td><button type="submit" name="view" value="Species Stats"><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></button></td>
</form>
</tr>
</table>
<h2>Today's Detections</h2>
<table>
<tr>
<th>Time</th>
<th>Listen</th>
<th>Scientific Name</th>
<th>Common Name</th>
<th>Confidence</th>
@@ -100,11 +103,13 @@ $speciestally = $result5->fetchArray(SQLITE3_ASSOC);
while($todaytable=$result0->fetchArray(SQLITE3_ASSOC))
{
$comname = preg_replace('/ /', '_', $todaytable['Com_Name']);
$comlink = "/By_Date/".date('Y-m-d')."/".$comname."/".$todaytable['File_Name'];
$comname = preg_replace('/\'/', '_', $comname);
$filename = "/By_Date/".date('Y-m-d')."/".$comname."/".$todaytable['File_Name'];
$sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);
?>
<tr>
<td><a href="<?php echo $comlink;?>" target="footer"/><?php echo $todaytable['Time'];?></a></td>
<td><?php echo $todaytable['Time'];?></td>
<td><audio controls><source src="<?php echo $filename;?>"></audio></td>
<td><a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top"><?php echo $todaytable['Sci_Name'];?></a></td>
<td><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $comname;?>" target="top"><?php echo $todaytable['Com_Name'];?></a></td>
<td><?php echo $todaytable['Confidence'];?></td>
-14
View File
@@ -26,25 +26,11 @@ $fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
session_start();
$_SESSION['success'] = 1;
if(isset($_POST["normal"])){
header('Location:config.php');
}else{
header('Location:../../');
}
$language = $_POST["language"];
if ($language != "none"){
$command = "sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";
$command_output = `$command`;
session_start();
$_SESSION['success'] = 1;
if(isset($_POST["normal"])){
header('Location:config.php');
}else{
header('Location:../../');
}
}
?>