Allow specific recordings to be "delete protected" from disk-check.sh
@mcguirepr89 I'm very happy with how this turned out! 😄
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 330 330" style="enable-background:new 0 0 330 330;" xml:space="preserve">
|
||||||
|
<g id="XMLID_504_">
|
||||||
|
<path id="XMLID_505_" d="M65,330h200c8.284,0,15-6.716,15-15V145c0-8.284-6.716-15-15-15h-15V85c0-46.869-38.131-85-85-85
|
||||||
|
S80,38.131,80,85v45H65c-8.284,0-15,6.716-15,15v170C50,323.284,56.716,330,65,330z M207.481,219.356l-42.5,42.5
|
||||||
|
c-2.929,2.929-6.768,4.394-10.606,4.394s-7.678-1.465-10.606-4.394l-21.25-21.25c-5.858-5.858-5.858-15.354,0-21.213
|
||||||
|
c5.857-5.858,15.355-5.858,21.213,0l10.644,10.643l31.894-31.893c5.857-5.858,15.355-5.858,21.213,0
|
||||||
|
C213.34,204.002,213.34,213.498,207.481,219.356z M110,85c0-30.327,24.673-55,55-55s55,24.673,55,55v45H110V85z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 330 330" style="enable-background:new 0 0 330 330;" xml:space="preserve">
|
||||||
|
<g id="XMLID_516_">
|
||||||
|
<path id="XMLID_517_" d="M15,160c8.284,0,15-6.716,15-15V85c0-30.327,24.673-55,55-55c30.327,0,55,24.673,55,55v45h-25
|
||||||
|
c-8.284,0-15,6.716-15,15v170c0,8.284,6.716,15,15,15h200c8.284,0,15-6.716,15-15V145c0-8.284-6.716-15-15-15H170V85
|
||||||
|
c0-46.869-38.131-85-85-85S0,38.131,0,85v60C0,153.284,6.716,160,15,160z"/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 829 B |
@@ -204,7 +204,7 @@ if (file_exists('./scripts/thisrun.txt')) {
|
|||||||
<input name="full_disk" type="radio" id="purge" value="purge" <?php if (strcmp($newconfig['FULL_DISK'], "purge") == 0) { echo "checked"; }?>>Purge</label>
|
<input name="full_disk" type="radio" id="purge" value="purge" <?php if (strcmp($newconfig['FULL_DISK'], "purge") == 0) { echo "checked"; }?>>Purge</label>
|
||||||
<label for="keep">
|
<label for="keep">
|
||||||
<input name="full_disk" type="radio" id="keep" value="keep" <?php if (strcmp($newconfig['FULL_DISK'], "keep") == 0) { echo "checked"; }?>>Keep</label>
|
<input name="full_disk" type="radio" id="keep" value="keep" <?php if (strcmp($newconfig['FULL_DISK'], "keep") == 0) { echo "checked"; }?>>Keep</label>
|
||||||
<p>When the disk becomes full, you can choose to 'purge' old files to make room for new ones or 'keep' your data and stop all services instead.</p>
|
<p>When the disk becomes full, you can choose to 'purge' old files to make room for new ones or 'keep' your data and stop all services instead.<br>Note: you can exclude specific files from 'purge' on the Recordings page.</p>
|
||||||
<label for="rec_card">Audio Card: </label>
|
<label for="rec_card">Audio Card: </label>
|
||||||
<input name="rec_card" type="text" value="<?php print($newconfig['REC_CARD']);?>" required/><br>
|
<input name="rec_card" type="text" value="<?php print($newconfig['REC_CARD']);?>" required/><br>
|
||||||
<p>Set Audio Card to 'default' to use PulseAudio (always recommended), or an ALSA recognized sound card device from the output of `aplay -L`.</p>
|
<p>Set Audio Card to 'default' to use PulseAudio (always recommended), or an ALSA recognized sound card device from the output of `aplay -L`.</p>
|
||||||
|
|||||||
+102
-9
@@ -9,6 +9,43 @@ if($db == False){
|
|||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_exists('./scripts/thisrun.txt')) {
|
||||||
|
$config = parse_ini_file('./scripts/thisrun.txt');
|
||||||
|
} elseif (file_exists('firstrun.ini')) {
|
||||||
|
$config = parse_ini_file('firstrun.ini');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
||||||
|
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
||||||
|
$home = trim($home);
|
||||||
|
|
||||||
|
if(isset($_GET['excludefile'])) {
|
||||||
|
if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) {
|
||||||
|
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end");
|
||||||
|
}
|
||||||
|
if(isset($_GET['exclude_add'])) {
|
||||||
|
$myfile = fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "a") or die("Unable to open file!");
|
||||||
|
$txt = $_GET['excludefile'];
|
||||||
|
fwrite($myfile, $txt."\n");
|
||||||
|
fwrite($myfile, $txt.".png\n");
|
||||||
|
fclose($myfile);
|
||||||
|
echo "OK";
|
||||||
|
die();
|
||||||
|
} else {
|
||||||
|
$lines = file($home."/BirdNET-Pi/scripts/disk_check_exclude.txt");
|
||||||
|
$search = $_GET['excludefile'];
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
foreach($lines as $line) {
|
||||||
|
if(stripos($line, $search) === false && stripos($line, $search.".png") === false) {
|
||||||
|
$result .= $line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", $result);
|
||||||
|
echo "OK";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($_GET['bydate'])){
|
if(isset($_GET['bydate'])){
|
||||||
$statement = $db->prepare('SELECT DISTINCT(Date) FROM detections GROUP BY Date ORDER BY Date DESC');
|
$statement = $db->prepare('SELECT DISTINCT(Date) FROM detections GROUP BY Date ORDER BY Date DESC');
|
||||||
@@ -70,9 +107,6 @@ if(isset($_GET['bydate'])){
|
|||||||
session_unset();
|
session_unset();
|
||||||
$view = "choose";
|
$view = "choose";
|
||||||
}
|
}
|
||||||
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
|
||||||
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
|
||||||
$home = trim($home);
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
@@ -83,6 +117,29 @@ $home = trim($home);
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleLock(filename, type, elem) {
|
||||||
|
const xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onload = function() {
|
||||||
|
if(type == "add") {
|
||||||
|
elem.setAttribute("src","images/lock.svg");
|
||||||
|
elem.setAttribute("title", "This file is delete protected.");
|
||||||
|
elem.setAttribute("onclick", elem.getAttribute("onclick").replace("add","del"));
|
||||||
|
} else {
|
||||||
|
elem.setAttribute("src","images/unlock.svg");
|
||||||
|
elem.setAttribute("title", "This file is not delete protected.");
|
||||||
|
elem.setAttribute("onclick", elem.getAttribute("onclick").replace("del","add"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(type == "add") {
|
||||||
|
xhttp.open("GET", "play.php?excludefile="+filename+"&exclude_add=true", true);
|
||||||
|
} else {
|
||||||
|
xhttp.open("GET", "play.php?excludefile="+filename+"&exclude_del=true", true);
|
||||||
|
}
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
#If no specific species
|
#If no specific species
|
||||||
if(!isset($_GET['species']) && !isset($_GET['filename'])){
|
if(!isset($_GET['species']) && !isset($_GET['filename'])){
|
||||||
@@ -104,7 +161,6 @@ if(!isset($_GET['species']) && !isset($_GET['filename'])){
|
|||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<form action="" method="GET">
|
<form action="" method="GET">
|
||||||
@@ -199,6 +255,7 @@ if(isset($_GET['species'])){ ?>
|
|||||||
$sci_name = $results['Sci_Name'];
|
$sci_name = $results['Sci_Name'];
|
||||||
$time = $results['Time'];
|
$time = $results['Time'];
|
||||||
$confidence = $results['Confidence'];
|
$confidence = $results['Confidence'];
|
||||||
|
$filename_formatted = $date."/".$comname."/".$results['File_Name'];
|
||||||
|
|
||||||
// file was deleted by disk check, no need to show the detection in recordings
|
// file was deleted by disk check, no need to show the detection in recordings
|
||||||
if(!file_exists($home."/BirdSongs/Extracted/".$filename)) {
|
if(!file_exists($home."/BirdSongs/Extracted/".$filename)) {
|
||||||
@@ -206,13 +263,31 @@ if(isset($_GET['species'])){ ?>
|
|||||||
}
|
}
|
||||||
$iter++;
|
$iter++;
|
||||||
|
|
||||||
|
if($config["FULL_DISK"] == "purge") {
|
||||||
|
if(trim(shell_exec("cat ".$home."/BirdNET-Pi/scripts/disk_check_exclude.txt | grep \"".$filename_formatted."\" | wc -l")) == "0") {
|
||||||
|
$imageicon = "images/unlock.svg";
|
||||||
|
$title = "This file is not delete protected.";
|
||||||
|
$type = "add";
|
||||||
|
} else {
|
||||||
|
$imageicon = "images/lock.svg";
|
||||||
|
$title = "This file is delete protected.";
|
||||||
|
$type = "del";
|
||||||
|
}
|
||||||
|
|
||||||
echo "<tr>
|
echo "<tr>
|
||||||
<td>$date $time<br>$confidence<br>
|
<td class='relative'>$date $time<br>$confidence<br><img style='cursor:pointer' onclick='toggleLock(\"".$filename_formatted."\",\"".$type."\", this)' class=\"copyimage\" width=25 title=\"".$title."\" src=\"".$imageicon."\">
|
||||||
<a href=\"$filename\"><img src=\"$filename.png\"></a>
|
<a href=\"$filename\"><img src=\"$filename.png\"></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
} else {
|
||||||
|
echo "<tr>
|
||||||
|
<td class='relative'>$date $time<br>$confidence<br>
|
||||||
|
<a href=\"$filename\"><img src=\"$filename.png\"></a>
|
||||||
|
</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
}if($iter == 0){ echo "<tr><td><b>No recordings were found on this date.</b><br><br><span style='font-size:small'>They may have been deleted to make space for new recordings. You can modify this setting for the future in Tools -> Settings -> Advanced Settings -> Full Disk Behavior.</small></td></tr>";}echo "</table>";}
|
}if($iter == 0){ echo "<tr><td><b>No recordings were found.</b><br><br><span style='font-size:small'>They may have been deleted to make space for new recordings. You can modify this setting for the future in Tools -> Settings -> Advanced Settings -> Full Disk Behavior.</small></td></tr>";}echo "</table>";}
|
||||||
|
|
||||||
if(isset($_GET['filename'])){
|
if(isset($_GET['filename'])){
|
||||||
$name = $_GET['filename'];
|
$name = $_GET['filename'];
|
||||||
@@ -236,11 +311,29 @@ if(isset($_GET['filename'])){
|
|||||||
$sci_name = $results['Sci_Name'];
|
$sci_name = $results['Sci_Name'];
|
||||||
$time = $results['Time'];
|
$time = $results['Time'];
|
||||||
$confidence = $results['Confidence'];
|
$confidence = $results['Confidence'];
|
||||||
|
$filename_formatted = $date."/".$comname."/".$results['File_Name'];
|
||||||
|
|
||||||
|
if($config["FULL_DISK"] == "purge") {
|
||||||
|
if(trim(shell_exec("cat ".$home."/BirdNET-Pi/scripts/disk_check_exclude.txt | grep \"".$filename_formatted."\" | wc -l")) == "0") {
|
||||||
|
$imageicon = "images/unlock.svg";
|
||||||
|
$title = "This file is not delete protected.";
|
||||||
|
$type = "add";
|
||||||
|
} else {
|
||||||
|
$imageicon = "images/lock.svg";
|
||||||
|
$title = "This file is delete protected.";
|
||||||
|
$type = "del";
|
||||||
|
}
|
||||||
|
|
||||||
echo "<tr>
|
echo "<tr>
|
||||||
<td>$date $time<br>$confidence<br>
|
<td class=\"relative\"><img style='cursor:pointer' onclick='toggleLock(\"".$filename_formatted."\",\"".$type."\", this)' class=\"copyimage\" width=25 title=\"".$title."\" src=\"".$imageicon."\">$date $time<br>$confidence<br>
|
||||||
<a href=\"$filename\"><img src=\"$filename\"></a>
|
<video onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster=\"$filename.png\" preload=\"none\" title=\"$filename\"><source src=\"$filename\"></video></td>
|
||||||
</td>
|
|
||||||
</tr>";
|
</tr>";
|
||||||
|
} else {
|
||||||
|
echo "<tr>
|
||||||
|
<td class=\"relative\">$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>";}?>
|
}echo "</table>";}?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+18
-5
@@ -56,7 +56,18 @@ if(isset($_GET['species'])){
|
|||||||
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
||||||
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
||||||
$home = trim($home);
|
$home = trim($home);
|
||||||
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "");
|
if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt")) {
|
||||||
|
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end");
|
||||||
|
}
|
||||||
|
function editfile( $sourcefile, $start='##start', $end='##end', $data=array() ){
|
||||||
|
$lines=array_filter( file( $sourcefile , FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ) );
|
||||||
|
$output=array_merge(
|
||||||
|
array_splice( $lines, 0, array_search( strtolower( $start ), array_map('strtolower', $lines ) ) + 1 ),
|
||||||
|
$data,
|
||||||
|
array_splice( $lines, array_search( strtolower( $end ), array_map('strtolower', $lines ) ) )
|
||||||
|
);
|
||||||
|
file_put_contents( $sourcefile, implode( PHP_EOL, $output ) );
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -151,21 +162,22 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){
|
|||||||
if($pos !== 1 && strpos($link, "upload") == true && strpos($link, "CentralAutoLogin") == false)
|
if($pos !== 1 && strpos($link, "upload") == true && strpos($link, "CentralAutoLogin") == false)
|
||||||
echo "<img src=\"$link\">";
|
echo "<img src=\"$link\">";
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<?php
|
<?php
|
||||||
|
$excludelines = [];
|
||||||
while($results=$result->fetchArray(SQLITE3_ASSOC))
|
while($results=$result->fetchArray(SQLITE3_ASSOC))
|
||||||
{
|
{
|
||||||
$comname = preg_replace('/ /', '_', $results['Com_Name']);
|
$comname = preg_replace('/ /', '_', $results['Com_Name']);
|
||||||
$comname = preg_replace('/\'/', '', $comname);
|
$comname = preg_replace('/\'/', '', $comname);
|
||||||
$filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name'];
|
$filename = "/By_Date/".$results['Date']."/".$comname."/".$results['File_Name'];
|
||||||
|
|
||||||
$excludefile = fopen($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "a") or die("Unable to open file!");
|
array_push($excludelines, $results['Date']."/".$comname."/".$results['File_Name']);
|
||||||
$txt = $results['Date']."/".$comname."/".$results['File_Name']."\n".$results['Date']."/".$comname."/".$results['File_Name'].".png\n";
|
array_push($excludelines, $results['Date']."/".$comname."/".$results['File_Name'].".png");
|
||||||
fwrite($excludefile, $txt);
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<form action="" method="GET">
|
<form action="" method="GET">
|
||||||
@@ -176,6 +188,7 @@ fwrite($excludefile, $txt);
|
|||||||
<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>
|
<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>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
editfile($home."/BirdNET-Pi/scripts/disk_check_exclude.txt","##start","##end",$excludelines);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user