rewritten php and some python for SQLITE
This commit is contained in:
Binary file not shown.
+7
-19
@@ -1,9 +1,8 @@
|
|||||||
#!/home/pi/BirdNET-Pi/birdnet/bin/python3
|
#!/home/pi/BirdNET-Pi/birdnet/bin/python3
|
||||||
|
|
||||||
import mysql.connector as sql
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import seaborn as sns
|
import seaborn as sns
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
@@ -11,25 +10,14 @@ from matplotlib.colors import LogNorm
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
#Extract DB_PWD from thisrun.txt
|
conn = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db')
|
||||||
with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
|
df = pd.read_sql_query("SELECT * from detections", conn)
|
||||||
this_run = f.readlines()
|
cursor = conn.cursor()
|
||||||
db_pwd = str(str(str([i for i in this_run if i.startswith('DB_PWD')]).split('=')[1]).split('\\')[0])
|
cursor.execute('SELECT * FROM detections')
|
||||||
|
|
||||||
|
table_rows = cursor.fetchall()
|
||||||
|
|
||||||
db_connection = sql.connect(host='localhost',
|
#df=pd.DataFrame(table_rows)
|
||||||
database='birds',
|
|
||||||
user='birder',
|
|
||||||
password=db_pwd)
|
|
||||||
|
|
||||||
|
|
||||||
db_cursor=db_connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
db_cursor.execute('SELECT * FROM detections')
|
|
||||||
|
|
||||||
table_rows = db_cursor.fetchall()
|
|
||||||
|
|
||||||
df=pd.DataFrame(table_rows)
|
|
||||||
|
|
||||||
#Convert Date and Time Fields to Panda's format
|
#Convert Date and Time Fields to Panda's format
|
||||||
df['Date']=pd.to_datetime(df['Date'])
|
df['Date']=pd.to_datetime(df['Date'])
|
||||||
|
|||||||
@@ -61,14 +61,13 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
SCIENTIFIC_NAME=""$(echo ${line} \
|
SCIENTIFIC_NAME=""$(echo ${line} \
|
||||||
| awk -F\; '!/birdnet/{print $3}')""
|
| awk -F\; '!/birdnet/{print $3}')""
|
||||||
CONFIDENCE=""$(echo ${line} \
|
CONFIDENCE=""$(echo ${line} \
|
||||||
| awk -F\; '{print $5}' \
|
| awk -F\; '{print $5}')""
|
||||||
| cut -d'.' -f2)""
|
|
||||||
CONFIDENCE_SCORE="${CONFIDENCE:0:2}%"
|
#CONFIDENCE_SCORE="${CONFIDENCE:0:2}%"
|
||||||
|
CONFIDENCE_SCORE="$(printf %.0f $(echo "scale=2; ${CONFIDENCE} * 100" | bc))"
|
||||||
NEWFILE="${COMMON_NAME// /_}-${CONFIDENCE_SCORE}-${OLDFILE//.wav/.${AUDIOFMT}}"
|
NEWFILE="${COMMON_NAME// /_}-${CONFIDENCE_SCORE}-${OLDFILE//.wav/.${AUDIOFMT}}"
|
||||||
echo "NEWFILE=$NEWFILE"
|
echo "NEWFILE=$NEWFILE"
|
||||||
NEWSPECIES_BYDATE="${EXTRACTED}/By_Date/${DATE}/${COMMON_NAME// /_}"
|
NEWSPECIES_BYDATE="${EXTRACTED}/By_Date/${DATE}/${COMMON_NAME// /_}"
|
||||||
NEWSPECIES_BY_COMMON="${EXTRACTED}/By_Common_Name/${COMMON_NAME// /_}"
|
|
||||||
NEWSPECIES_BY_SCIENCE="${EXTRACTED}/By_Scientific_Name/${SCIENTIFIC_NAME// /_}"
|
|
||||||
|
|
||||||
# If the extracted file already exists, move on
|
# If the extracted file already exists, move on
|
||||||
if [[ -f "${NEWSPECIES_BYDATE}/${NEWFILE}" ]];then
|
if [[ -f "${NEWSPECIES_BYDATE}/${NEWFILE}" ]];then
|
||||||
@@ -85,16 +84,6 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
# it is created
|
# it is created
|
||||||
[[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}"
|
[[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}"
|
||||||
|
|
||||||
|
|
||||||
# If a directory does not already exist for the species (by-species),
|
|
||||||
# it is created.
|
|
||||||
[[ -d "${NEWSPECIES_BY_COMMON}" ]] || mkdir -p "${NEWSPECIES_BY_COMMON}"
|
|
||||||
|
|
||||||
# If a directory does not already exist for the species (by-species),
|
|
||||||
# it is created.
|
|
||||||
[[ -d "${NEWSPECIES_BY_SCIENCE}" ]] || mkdir -p "${NEWSPECIES_BY_SCIENCE}"
|
|
||||||
|
|
||||||
|
|
||||||
# If there are already 20 extracted entries for a given species
|
# If there are already 20 extracted entries for a given species
|
||||||
# for today, remove the oldest file and create the new one.
|
# for today, remove the oldest file and create the new one.
|
||||||
# if [[ "$(find ${NEWSPECIES_BYDATE} | wc -l)" -ge 20 ]];then
|
# if [[ "$(find ${NEWSPECIES_BYDATE} | wc -l)" -ge 20 ]];then
|
||||||
@@ -131,9 +120,6 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
|
|
||||||
sox "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
sox "${h}/${OLDFILE}" "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
||||||
trim "${START}" "${END}"
|
trim "${START}" "${END}"
|
||||||
#ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
|
|
||||||
# -acodec copy -ss "${START}" -to "${END}"\
|
|
||||||
# "${NEWSPECIES_BYDATE}/${NEWFILE}"
|
|
||||||
|
|
||||||
# Create spectrogram for extraction
|
# Create spectrogram for extraction
|
||||||
sox "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \
|
sox "${NEWSPECIES_BYDATE}/${NEWFILE}" -n remix 1 rate 24k spectrogram \
|
||||||
@@ -141,48 +127,6 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
-c "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
-c "${NEWSPECIES_BYDATE}/${NEWFILE}" \
|
||||||
-o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"
|
-o "${NEWSPECIES_BYDATE}/${NEWFILE}.png"
|
||||||
|
|
||||||
# Remove the oldest symbolic links that would make the directory have more
|
|
||||||
# than 20 entries.
|
|
||||||
if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 40 ]];then
|
|
||||||
echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one"
|
|
||||||
cd ${NEWSPECIES_BY_COMMON} || exit 1
|
|
||||||
ls -1t . | tail -n +40 | xargs -r rm -vv
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\
|
|
||||||
"${NEWSPECIES_BY_COMMON}/${NEWFILE}"
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\
|
|
||||||
"${NEWSPECIES_BY_COMMON}/${NEWFILE}.png"
|
|
||||||
echo "Success! New extraction for ${COMMON_NAME}"
|
|
||||||
else
|
|
||||||
# Make symbolic link of the extraction to add to By_Common_Name
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\
|
|
||||||
"${NEWSPECIES_BY_COMMON}/${NEWFILE}"
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\
|
|
||||||
"${NEWSPECIES_BY_COMMON}/${NEWFILE}.png"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the oldest symbolic links that would made the directory have more
|
|
||||||
# than 20 entries.
|
|
||||||
if [[ "$(find ${NEWSPECIES_BY_SCIENCE} | wc -l)" -ge 40 ]];then
|
|
||||||
echo "20 ${SPECIES}s, already! Removing the oldest by-species and making a new one"
|
|
||||||
cd ${NEWSPECIES_BY_SCIENCE} || exit 1
|
|
||||||
ls -1t . | tail -n +40 | xargs -r rm -vv
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\
|
|
||||||
"${NEWSPECIES_BY_SCIENCE}/${NEWFILE}"
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\
|
|
||||||
"${NEWSPECIES_BY_SCIENCE}/${NEWFILE}.png"
|
|
||||||
echo "Success! New extraction for ${COMMON_NAME}"
|
|
||||||
else
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}"\
|
|
||||||
"${NEWSPECIES_BY_SCIENCE}/${NEWFILE}"
|
|
||||||
ln -fs "${NEWSPECIES_BYDATE}/${NEWFILE}.png"\
|
|
||||||
"${NEWSPECIES_BY_SCIENCE}/${NEWFILE}.png"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Finally, 'a' is incremented by one to allow multiple extractions per
|
|
||||||
# species per minute.
|
|
||||||
#a=$((a + 1))
|
|
||||||
|
|
||||||
done < "${TMPFILE}"
|
done < "${TMPFILE}"
|
||||||
|
|
||||||
# Once each line of the TMPFILE has been processed, the TMPFILE is emptied
|
# Once each line of the TMPFILE has been processed, the TMPFILE is emptied
|
||||||
@@ -192,11 +136,11 @@ for h in "${SCAN_DIRS[@]}";do
|
|||||||
# Rename files that have been processed so that they are not processed on the
|
# Rename files that have been processed so that they are not processed on the
|
||||||
# next extraction.
|
# next extraction.
|
||||||
[[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}"
|
[[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}"
|
||||||
echo "Moving processed files to ${PROCESSED}"
|
#echo "Moving processed files to ${PROCESSED}"
|
||||||
mv ${h}/* ${PROCESSED} &> /dev/null || continue
|
mv ${h}/* ${PROCESSED} &> /dev/null || continue
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Linking Processed files to "${EXTRACTED}/Processed" web directory"
|
#echo "Linking Processed files to "${EXTRACTED}/Processed" web directory"
|
||||||
# After all audio extractions have taken place, a directory is created to house
|
# After all audio extractions have taken place, a directory is created to house
|
||||||
# the original WAVE and .txt files used for this extraction processs.
|
# the original WAVE and .txt files used for this extraction processs.
|
||||||
if [[ ! -L ${EXTRACTED}/Processed ]] || [[ ! -e ${EXTRACTED}/Processed ]];then
|
if [[ ! -L ${EXTRACTED}/Processed ]] || [[ ! -e ${EXTRACTED}/Processed ]];then
|
||||||
|
|||||||
+9
-1
@@ -10,6 +10,14 @@ $theDate = date('Y-m-d');
|
|||||||
}
|
}
|
||||||
$chart = "Combo-$theDate.png";
|
$chart = "Combo-$theDate.png";
|
||||||
$chart2 = "Combo2-$theDate.png";
|
$chart2 = "Combo2-$theDate.png";
|
||||||
|
|
||||||
|
$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||||
|
|
||||||
|
$statement1 = $db->prepare("SELECT COUNT(*) FROM detections
|
||||||
|
WHERE Date == \"$theDate\"");
|
||||||
|
$result1 = $statement1->execute();
|
||||||
|
$totalcount = $result1->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@@ -52,7 +60,7 @@ hr {
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total Detections For The Day</th>
|
<th>Total Detections For The Day</th>
|
||||||
<td></td>
|
<td><?php echo $totalcount['COUNT(*)'];?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ $statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE TIME >= TIME(\
|
|||||||
$result3 = $statement3->execute();
|
$result3 = $statement3->execute();
|
||||||
$hourcount = $result3->fetchArray(SQLITE3_ASSOC);
|
$hourcount = $result3->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Time, Confidence FROM detections LIMIT 1');
|
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Time ASC LIMIT 1');
|
||||||
$result4 = $statement4->execute();
|
$result4 = $statement4->execute();
|
||||||
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
|
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
|
||||||
$comlink = preg_replace('/ /', '_', $mostrecent['Com_Name']);
|
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
|
||||||
$scilink = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
|
$scilink = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
|
||||||
|
|
||||||
$statement5 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections WHERE Date == Date(\'now\')');
|
$statement5 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections WHERE Date == Date(\'now\')');
|
||||||
@@ -70,8 +70,8 @@ a {
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Most Recent Detection</th>
|
<th>Most Recent Detection</th>
|
||||||
<td><a href="/By_Date/<?php echo $myDate."/".$comlink;?>"><?php echo $mostrecent['Com_Name'];?></a></td>
|
<td><a href="/By_Date/<?php echo $myDate."/".$comname;?>"><?php echo $mostrecent['Com_Name'];?></a></td>
|
||||||
<td><a href="/By_Date/<?php echo$myDate;?>"/><?php echo $mostrecent['Time'];?></a></td>
|
<td><a href="/By_Date/<?php echo$myDate."/".$comname."/".$mostrecent['File_Name'];?>" target="footer"/><?php echo $mostrecent['Date']." ".$mostrecent['Time'];?></a></td>
|
||||||
<td><?php echo $mostrecent['Confidence'];?></td>
|
<td><?php echo $mostrecent['Confidence'];?></td>
|
||||||
<td><a href="https://wikipedia.org/wiki/<?php echo $scilink;?>" target="top"/>More Info</a></td>
|
<td><a href="https://wikipedia.org/wiki/<?php echo $scilink;?>" target="top"/>More Info</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -91,7 +91,7 @@ a {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Number of Detections</th>
|
<th>Number of Detections</th>
|
||||||
<td><?php echo $totalcount['COUNT(*)'];?></td>
|
<td><?php echo $totalcount['COUNT(*)'];?></td>
|
||||||
<td><?php echo $todaycount['COUNT(*)'];?></td>
|
<td><a href="/By_Date/<?php echo date('Y-m-d');?>"/><?php echo $todaycount['COUNT(*)'];?></a></td>
|
||||||
<td><?php echo $hourcount['COUNT(*)'];?></td>
|
<td><?php echo $hourcount['COUNT(*)'];?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -100,7 +100,7 @@ a {
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Species Detected Today</th>
|
<th>Species Detected Today</th>
|
||||||
<td><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></td>
|
<td><a href="/stats.php"/><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+2
-2
@@ -302,7 +302,7 @@ def handle_client(conn, addr):
|
|||||||
#print('Time:', date_time_obj.time())
|
#print('Time:', date_time_obj.time())
|
||||||
print('Date-time:', date_time_obj)
|
print('Date-time:', date_time_obj)
|
||||||
now = date_time_obj
|
now = date_time_obj
|
||||||
current_date = now.strftime("%Y/%m/%d")
|
current_date = now.strftime("%Y-%m-%d")
|
||||||
current_time = now.strftime("%H:%M:%S")
|
current_time = now.strftime("%H:%M:%S")
|
||||||
current_iso8601 = now.astimezone(get_localzone()).isoformat()
|
current_iso8601 = now.astimezone(get_localzone()).isoformat()
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ def handle_client(conn, addr):
|
|||||||
species = entry[0]
|
species = entry[0]
|
||||||
Sci_Name,Com_Name = species.split('_')
|
Sci_Name,Com_Name = species.split('_')
|
||||||
score = entry[1]
|
score = entry[1]
|
||||||
Confidence = "{:.0%}".format(score)
|
Confidence = str(round(score*100))
|
||||||
Lat = str(args.lat)
|
Lat = str(args.lat)
|
||||||
Lon = str(args.lon)
|
Lon = str(args.lon)
|
||||||
Cutoff = str(args.min_conf)
|
Cutoff = str(args.min_conf)
|
||||||
|
|||||||
+49
-32
@@ -3,6 +3,20 @@ ini_set('display_errors', 1);
|
|||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||||
|
|
||||||
|
$statement = $db->prepare('SELECT Com_Name, COUNT(*), MAX(Confidence), Sci_Name FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC');
|
||||||
|
$result = $statement->execute();
|
||||||
|
|
||||||
|
$statement2 = $db->prepare('SELECT Com_Name FROM detections GROUP BY Com_Name ORDER BY Com_Name ASC');
|
||||||
|
$result2 = $statement2->execute();
|
||||||
|
|
||||||
|
if(isset($_POST['species'])){
|
||||||
|
$selection = $_POST['species'];
|
||||||
|
$statement3 = $db->prepare("SELECT Com_Name, Sci_Name, COUNT(*), MAX(Confidence) from detections
|
||||||
|
WHERE Com_Name = '$selection'");
|
||||||
|
$result3 = $statement3->execute();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -116,21 +130,6 @@ form {
|
|||||||
<section>
|
<section>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column first">
|
<div class="column first">
|
||||||
<h3>Number of Detections</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>Total</th>
|
|
||||||
<th>Today</th>
|
|
||||||
<th>Last Hour</th>
|
|
||||||
<th>Number of Unique Species</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Summary</h3>
|
<h3>Summary</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -138,22 +137,40 @@ form {
|
|||||||
<th>Occurrences</th>
|
<th>Occurrences</th>
|
||||||
<th>Max Confidence Score</th>
|
<th>Max Confidence Score</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
while($results=$result->fetchArray(SQLITE3_ASSOC))
|
||||||
|
{
|
||||||
|
$comname = preg_replace('/ /', '_', $results['Com_Name']);
|
||||||
|
$comlink = "/By_Date/".date('Y-m-d')."/".$comname;
|
||||||
|
$sciname = preg_replace('/ /', '_', $results['Sci_Name']);
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="../By_Common_Name/"></a></td>
|
<td><?php echo $results['Com_Name'];?></td>
|
||||||
<td></td>
|
<td><?php echo $results['COUNT(*)'];?></td>
|
||||||
<td></td>
|
<td><?php echo $results['MAX(Confidence)'];?></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<form action="stats.php" method="POST">
|
<form action="stats.php" method="POST">
|
||||||
<h3>Species Stats</h3>
|
<h3>Species Stats</h3>
|
||||||
<select name="species" >
|
<select name="species" >
|
||||||
<option value=""></option>
|
<option value="<?php if(isset($_POST['species'])){echo $selection;}?>"><?php if(isset($_POST['species'])){echo $selection;}else{echo "--Choose Species--";}?></option>
|
||||||
<option value=""></option>"
|
<?php
|
||||||
|
while($results=$result2->fetchArray(SQLITE3_ASSOC))
|
||||||
|
{
|
||||||
|
$comname = preg_replace('/ /', '_', $results['Com_Name']);
|
||||||
|
$comlink = "/By_Date/".date('Y-m-d')."/".$comname;
|
||||||
|
$sciname = preg_replace('/ /', '_', $results['Sci_Name']);
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $results['Com_Name'];?>"><?php echo $results['Com_Name'];?></option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
|
||||||
<button type="submit" class="block"/>Show Species Statistics</button>
|
<button type="submit" class="block"/>Show Species Statistics</button>
|
||||||
</form>
|
</form>
|
||||||
<?php if(isset($_POST['species'])){
|
<?php if(isset($_POST['species'])){
|
||||||
@@ -171,22 +188,22 @@ form {
|
|||||||
ob_flush();
|
ob_flush();
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
while($rows = $specificstats->fetch_assoc()) {
|
while($results=$result3->fetchArray(SQLITE3_ASSOC)){
|
||||||
$count = $rows['COUNT(*)'];
|
$count = $results['COUNT(*)'];
|
||||||
$maxconf = $rows['MAX(Confidence)'];
|
$maxconf = $results['MAX(Confidence)'];
|
||||||
$name = $rows['Com_Name'];
|
$name = $results['Com_Name'];
|
||||||
$sciname = $rows['Sci_Name'];
|
$sciname = $results['Sci_Name'];
|
||||||
$dbname = preg_replace('/ /', '_', $rows['Com_Name']);
|
$dbname = preg_replace('/ /', '_', $results['Com_Name']);
|
||||||
$dbname = preg_replace('/\'/', '', $dbname);
|
$dbname = preg_replace('/\'/', '', $dbname);
|
||||||
$dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']);
|
$dbsciname = preg_replace('/ /', '_', $results['Sci_Name']);
|
||||||
$imagelink = shell_exec("/home/pi/BirdNET-Pi/scripts/get_image.sh $dbsciname");
|
$imagelink = shell_exec("/home/pi/BirdNET-Pi/scripts/get_image.sh $dbsciname");
|
||||||
$imagecitation = shell_exec("/home/pi/BirdNET-Pi/scripts/get_citation.sh $dbsciname");
|
$imagecitation = shell_exec("/home/pi/BirdNET-Pi/scripts/get_citation.sh $dbsciname");
|
||||||
$str= "<tr>
|
$str= "<tr>
|
||||||
<td><a href=\"../By_Common_Name/$dbname\"/>$name</a></td>
|
<td>$name</td>
|
||||||
<td><a href=\"../By_Scientific_Name/$dbsciname\"/>$sciname</a></td>
|
<td><a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/>$sciname</a></td>
|
||||||
<td>$count</td>
|
<td>$count</td>
|
||||||
<td>$maxconf</td>
|
<td>$maxconf</td>
|
||||||
<td><a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/>Wikipedia</a>, <a href=\"https://allaboutbirds.org/guide/$dbname\" target=\"top\"/>All About Birds</a>
|
<td><a href=\"https://allaboutbirds.org/guide/$dbname\" target=\"top\"/>All About Birds</a>
|
||||||
</tr>
|
</tr>
|
||||||
</table>";
|
</table>";
|
||||||
echo str_pad($str, 4096);
|
echo str_pad($str, 4096);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ services=(birdnet_recording.service
|
|||||||
birdnet_analysis.service
|
birdnet_analysis.service
|
||||||
birdnet_server.service
|
birdnet_server.service
|
||||||
chart_viewer.service
|
chart_viewer.service
|
||||||
extraction.timer
|
extraction.service
|
||||||
spectrogram_viewer.service)
|
spectrogram_viewer.service)
|
||||||
|
|
||||||
for i in "${services[@]}";do
|
for i in "${services[@]}";do
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ spectrogram_viewer.service
|
|||||||
pushed_notifications.service
|
pushed_notifications.service
|
||||||
livestream.service
|
livestream.service
|
||||||
icecast2.service
|
icecast2.service
|
||||||
extraction.timer
|
|
||||||
extraction.service
|
extraction.service
|
||||||
chart_viewer.service
|
chart_viewer.service
|
||||||
birdnet_recording.service
|
birdnet_recording.service
|
||||||
|
|||||||
+42
-9
@@ -4,6 +4,31 @@ ini_set('display_startup_errors', 1);
|
|||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
header("refresh: 30;");
|
header("refresh: 30;");
|
||||||
|
|
||||||
|
$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||||
|
|
||||||
|
$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\') ORDER BY Time DESC');
|
||||||
|
$result0 = $statement0->execute();
|
||||||
|
|
||||||
|
$statement1 = $db->prepare('SELECT COUNT(*) FROM detections');
|
||||||
|
$result1 = $statement1->execute();
|
||||||
|
$totalcount = $result1->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
|
$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\')');
|
||||||
|
$result2 = $statement2->execute();
|
||||||
|
$todaycount = $result2->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
|
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
|
||||||
|
$result3 = $statement3->execute();
|
||||||
|
$hourcount = $result3->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
|
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Time, Confidence FROM detections LIMIT 1');
|
||||||
|
$result4 = $statement4->execute();
|
||||||
|
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
|
$statement5 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections');
|
||||||
|
$result5 = $statement5->execute();
|
||||||
|
$speciestally = $result5->fetchArray(SQLITE3_ASSOC);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -36,10 +61,10 @@ a {
|
|||||||
<th>Number of Unique Species</th>
|
<th>Number of Unique Species</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td><?php echo $totalcount['COUNT(*)'];?></td>
|
||||||
<td></td>
|
<td><a href="/By_Date/<?php echo date('Y-m-d');?>"/><?php echo $todaycount['COUNT(*)'];?></a></td>
|
||||||
<td></td>
|
<td><?php echo $hourcount['COUNT(*)'];?></td>
|
||||||
<td></td>
|
<td><a href="/stats.php"/><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -53,11 +78,19 @@ a {
|
|||||||
<th>Confidence</th>
|
<th>Confidence</th>
|
||||||
<th>Links</th>
|
<th>Links</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
while($todaytable=$result0->fetchArray(SQLITE3_ASSOC))
|
||||||
|
{
|
||||||
|
$comname = preg_replace('/ /', '_', $todaytable['Com_Name']);
|
||||||
|
$comlink = "/By_Date/".date('Y-m-d')."/".$comname."/".$todaytable['File_Name'];
|
||||||
|
$sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td><a href="<?php echo $comlink;?>" target="footer"/><?php echo $todaytable['Time'];?></a></td>
|
||||||
<td><a href="/By_Scientific_Name/"/></a></td>
|
<td><?php echo $todaytable['Sci_Name'];?></td>
|
||||||
<td><a href="/By_Common_Name/"/></a></td>
|
<td><?php echo $todaytable['Com_Name'];?></td>
|
||||||
<td></td>
|
<td><?php echo $todaytable['Confidence'];?></td>
|
||||||
<td><a class="a2" href="https://allaboutbirds.org/guide/" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/" target="top">Wikipedia</a></td>
|
<td><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $comname;?>" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top">Wikipedia</a></td>
|
||||||
|
<?php }?>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user