A live bird collage card for your Home Assistant dashboard.
Adding links to recordings
ehpersonal38b2c80f0db763
diff --git a/homepage/index.php b/homepage/index.phpindex c989aa9f..93dd9669 100644--- a/homepage/index.php+++ b/homepage/index.php@@ -54,6 +54,14 @@ if(isset($_GET['stream'])){<h1><a href=\"\">BirdNET-Pi</a><img src=\"images/version.svg\"></h1></div>";}+if(isset($_GET['filename'])) {+ $filename = $_GET['filename'];+echo "+<iframe src=\"/views.php?view=Recordings&filename=$filename\"></iframe>+</div>";+} else {echo "<iframe src=\"/views.php\"></iframe></div>";+}+diff --git a/homepage/style.css b/homepage/style.cssindex 56403aee..5dd558c7 100644--- a/homepage/style.css+++ b/homepage/style.css@@ -494,3 +494,14 @@ button:hover {display:none;}}++.copyimage {+ position:absolute;+ top: 7px;+ right: 7px;+ width: 25px !important;+ height: 25px !important;+}+.relative {+ position:relative;+}\ No newline at end of filediff --git a/scripts/overview.php b/scripts/overview.phpindex 697491f5..78ac7a61 100644--- a/scripts/overview.php+++ b/scripts/overview.php@@ -96,14 +96,14 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse</style><table class="<?php echo ($_GET['previous_detection_identifier'] == 'undefined') ? '' : 'fade-in'; ?>"><h3>Most Recent Detection: <span style="font-weight: normal;"><?php echo $mostrecent['Date']." ".$mostrecent['Time'];?></span></h3>- <tr>- <td>+ <tr class="relative">+ <td><a target="_blank" href="index.php?filename=<?php echo $mostrecent['File_Name']; ?>"><img class="copyimage" width="25" height="25" src="images/copy.png"></a><form action="" method="GET"><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><a href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="_blank"/><i><?php echo $mostrecent['Sci_Name'];?></i></a><br>Confidence: <?php echo $mostrecent['Confidence'];?><br>- <video style="margin-top: 10px;" onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>"></video></td>+ <video style="margin-top:10px" onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>"></video></td></form></tr></table> <?phpdiff --git a/scripts/play.php b/scripts/play.phpindex b893ac14..14533ad7 100644--- a/scripts/play.php+++ b/scripts/play.php@@ -10,7 +10,16 @@ if($db == False){}#By Date-if(isset($_GET['bydate'])){+if(isset($_GET['byfilename'])){+ $statement = $db->prepare('SELECT DISTINCT(Date) FROM detections GROUP BY Date');+ if($statement == False){+ echo "Database is busy";+ header("refresh: 0;");+ }+ $result = $statement->execute();+ $view = "bydate";+ #By Date+}elseif(isset($_GET['bydate'])){$statement = $db->prepare('SELECT DISTINCT(Date) FROM detections GROUP BY Date');if($statement == False){echo "Database is busy";@@ -75,7 +84,7 @@ if(isset($_GET['bydate'])){<?php#If no specific species-if(!isset($_GET['species'])){+if(!isset($_GET['species']) && !isset($_GET['filename'])){?><div class="play"><table>@@ -129,6 +138,35 @@ if(isset($_GET['species'])){header("refresh: 0;");}$result2 = $statement2->execute();+ echo "<table>+ <tr>+ <th>$name</th>+ </tr>";+ while($results=$result2->fetchArray(SQLITE3_ASSOC))+ {+ $comname = preg_replace('/ /', '_', $results['Com_Name']);+ $comname = preg_replace('/\'/', '', $comname);+ $date = $results['Date'];+ $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 class='relative'>+ <td><a target=\"_blank\" href=\"index.php?filename=".$results['File_Name']."\"><img class=\"copyimage\" width=25 src=\"images/copy.png\"></a>$date $time<br>$confidence<br>+ <video onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster=\"$filename.png\" preload=\"none\" title=\"$filename\"><source src=\"$filename\"></video></td>+ </tr>";++ }echo "</table>";}++if(isset($_GET['filename'])){+ $name = $_GET['filename'];+ $statement2 = $db->prepare("SELECT * FROM detections where File_name == \"$name\" ORDER BY Date DESC, Time DESC");+ if($statement2 == False){+ echo "Database is busy";+ header("refresh: 0;");+ }+ $result2 = $statement2->execute();echo "<table><tr><th>$name</th>diff --git a/scripts/stats.php b/scripts/stats.phpindex deb61617..9a0724c6 100644--- a/scripts/stats.php+++ b/scripts/stats.php@@ -5,20 +5,20 @@ error_reporting(E_ALL);$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);if($db == False) {- echo "Database busy";- header("refresh: 0;");+ echo "Database busy";+ header("refresh: 0;");}$statement = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC');if($statement == False) {- echo "Database busy";- header("refresh: 0;");+ echo "Database busy";+ header("refresh: 0;");}$result = $statement->execute();$statement2 = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY Com_Name');if($statement == False) {- echo "Database busy";- header("refresh: 0;");+ echo "Database busy";+ header("refresh: 0;");}$result2 = $statement2->execute();@@ -28,8 +28,8 @@ if(isset($_GET['species'])){$selection = $_GET['species'];$statement3 = $db->prepare("SELECT Com_Name, Sci_Name, COUNT(*), MAX(Confidence), File_Name, Date, Time from detections WHERE Com_Name = \"$selection\"");if($statement3 == False) {- echo "Database busy";- header("refresh: 0;");+ echo "Database busy";+ header("refresh: 0;");}$result3 = $statement3->execute();}@@ -89,8 +89,8 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){$linkname = preg_replace('/_/', '+', $dbsciname);$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];echo str_pad("<h3>$species</h3>- <table><tr>- <td><a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/><i>$sciname</i></a><br>+ <table><tr class=\"relative\">+ <td><a target=\"_blank\" href=\"index.php?filename=".$results['File_Name']."\"><img class=\"copyimage\" width=25 src=\"images/copy.png\"></a> <a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/><i>$sciname</i></a><br><b>Occurrences: </b>$count<br><b>Max Confidence: </b>$maxconf<br><b>Best Recording: </b>$date $time<br>@@ -122,9 +122,9 @@ $comname = preg_replace('/ /', '_', $results['Com_Name']);$comname = preg_replace('/\'/', '', $comname);$filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name'];?>- <tr>+ <tr class="relative"><form action="" method="GET">- <td><input type="hidden" name="view" value="Species Stats">+ <td><a target="_blank" href="index.php?filename=<?php echo $results['File_Name']; ?>"><img class="copyimage" width=25 src="images/copy.png"></a><input type="hidden" name="view" value="Species Stats"><button type="submit" name="species" value="<?php echo $results['Com_Name'];?>"><?php echo $results['Com_Name'];?></button><br><b>Occurrences:</b> <?php echo $results['COUNT(*)'];?><br><b>Max Confidence:</b> <?php echo $results['MAX(Confidence)'];?><br><b>Best Recording:</b> <?php echo $results['Date']." ".$results['Time'];?><br><video onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>" type="audio/mp3"></video></td>diff --git a/scripts/todays_detections.php b/scripts/todays_detections.phpindex f9b43198..94002bf1 100644--- a/scripts/todays_detections.php+++ b/scripts/todays_detections.php@@ -65,7 +65,8 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse}$result0 = $statement0->execute();- ?> <table> <?php+ ?> <table>+ <?php$iterations = 0;while($todaytable=$result0->fetchArray(SQLITE3_ASSOC)){@@ -76,8 +77,8 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse$filename = "/By_Date/".date('Y-m-d')."/".$comname."/".$todaytable['File_Name'];$sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);?>- <tr id="<?php echo $iterations; ?>">- <td><?php echo $todaytable['Time'];?><br>+ <tr class="relative" id="<?php echo $iterations; ?>">+ <td><a target="_blank" href="index.php?filename=<?php echo $todaytable['File_Name']; ?>"><img class="copyimage" width=25 src="images/copy.png"></a><?php echo $todaytable['Time'];?><br><b><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $comname;?>" target="top"><?php echo $todaytable['Com_Name'];?></a></b><br><a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top"><i><?php echo $todaytable['Sci_Name'];?></i></a><br><b>Confidence:</b> <?php echo $todaytable['Confidence'];?><br>