From bd0d44b9c9e69ff4b6200a9ecae96032c1cd6766 Mon Sep 17 00:00:00 2001 From: smashery Date: Tue, 21 Mar 2023 16:47:12 +1100 Subject: [PATCH 01/17] Fix de-sync between models and labels --- scripts/config.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index 6912af4..fc76879 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -107,20 +107,8 @@ if(isset($_GET["latitude"])){ } elseif (file_exists('./scripts/firstrun.ini')) { $lang_config = parse_ini_file('./scripts/firstrun.ini'); } - if ($language != $lang_config['DATABASE_LANG']){ - $user = trim(shell_exec("awk -F: '/1000/{print $1}' /etc/passwd")); - $home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd")); - // Archive old language file - syslog_shell_exec("cp -f $home/BirdNET-Pi/model/labels.txt $home/BirdNET-Pi/model/labels.txt.old", $user); - - // Install new language label file - syslog_shell_exec("$home/BirdNET-Pi/scripts/install_language_label.sh -l $language", $user); - - syslog(LOG_INFO, "Successfully changed language to '$language'"); - } - - if ($model != $lang_config['MODEL']){ + if ($model != $lang_config['MODEL'] || $language != $lang_config['DATABASE_LANG']){ $user = trim(shell_exec("awk -F: '/1000/{print $1}' /etc/passwd")); $home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd")); @@ -134,7 +122,7 @@ if(isset($_GET["latitude"])){ syslog_shell_exec("$home/BirdNET-Pi/scripts/install_language_label.sh -l $language", $user); } - syslog(LOG_INFO, "Successfully changed language to '$language'"); + syslog(LOG_INFO, "Successfully changed language to '$language' and model to '$model'"); } From 1a0bf359b32e588d34e7efd23b142d3ff9eadfc2 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 21 Mar 2023 17:41:36 -0400 Subject: [PATCH 02/17] Fix permissions issues, pt. 2 --- scripts/play.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/play.php b/scripts/play.php index 6dc91b0..943a93f 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -120,16 +120,16 @@ if(isset($_GET['shiftfile'])) { $soxopt = "-q"; $soxpitch = $config['FREQSHIFT_PITCH']; $cmd = "/usr/bin/nohup /usr/bin/sox \"".$pi.$filename."\" \"".$shifted_path.$filename."\" pitch ".$soxopt." ".$soxpitch; - shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh"); + shell_exec("sudo mkdir -p ".$shifted_path.$dir." && sudo echo \"".$cmd."\" > /tmp/shift.sh && sudo chmod +x /tmp/shift.sh"); } - shell_exec("/tmp/shift.sh"); - shell_exec("rm -f /tmp/shift.sh"); + shell_exec("sudo /tmp/shift.sh"); + shell_exec("sudo rm -f /tmp/shift.sh"); } else { $cmd = "rm -f " . $shifted_path.$filename; - shell_exec("echo \"".$cmd."\" > /tmp/unshift.sh && chmod +x /tmp/unshift.sh"); - shell_exec("/tmp/unshift.sh"); - shell_exec("rm -f /tmp/unshift.sh"); + shell_exec("sudo echo \"".$cmd."\" > /tmp/unshift.sh && sudo chmod +x /tmp/unshift.sh"); + shell_exec("sudo /tmp/unshift.sh"); + shell_exec("sudo rm -f /tmp/unshift.sh"); } echo "OK"; From 31cc358243065b6c876e023288f1117697d95b23 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:02:45 -0400 Subject: [PATCH 03/17] Removing /tmp/ file creation for pitch shifting Co-Authored-By: croisez <1774281+croisez@users.noreply.github.com> --- scripts/play.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/play.php b/scripts/play.php index 943a93f..49e1072 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -112,24 +112,19 @@ if(isset($_GET['shiftfile'])) { $freqshift_tool = $config['FREQSHIFT_TOOL']; if ($freqshift_tool == "ffmpeg") { - $cmd = "/usr/bin/nohup /usr/bin/ffmpeg -y -i \"".$pi.$filename."\" -af \"rubberband=pitch=".$config['FREQSHIFT_LO']."/".$config['FREQSHIFT_HI']."\" \"".$shifted_path.$filename."\""; - shell_exec("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && chmod +x /tmp/shift.sh"); + $cmd = "sudo /usr/bin/nohup /usr/bin/ffmpeg -y -i \"".$pi.$filename."\" -af \"rubberband=pitch=".$config['FREQSHIFT_LO']."/".$config['FREQSHIFT_HI']."\" \"".$shifted_path.$filename."\""; + shell_exec("sudo mkdir -p ".$shifted_path.$dir." && ".$cmd); } else if ($freqshift_tool == "sox") { //linux.die.net/man/1/sox $soxopt = "-q"; $soxpitch = $config['FREQSHIFT_PITCH']; - $cmd = "/usr/bin/nohup /usr/bin/sox \"".$pi.$filename."\" \"".$shifted_path.$filename."\" pitch ".$soxopt." ".$soxpitch; - shell_exec("sudo mkdir -p ".$shifted_path.$dir." && sudo echo \"".$cmd."\" > /tmp/shift.sh && sudo chmod +x /tmp/shift.sh"); + $cmd = "sudo /usr/bin/nohup /usr/bin/sox \"".$pi.$filename."\" \"".$shifted_path.$filename."\" pitch ".$soxopt." ".$soxpitch; + shell_exec("sudo mkdir -p ".$shifted_path.$dir." && ".$cmd); } - - shell_exec("sudo /tmp/shift.sh"); - shell_exec("sudo rm -f /tmp/shift.sh"); } else { - $cmd = "rm -f " . $shifted_path.$filename; - shell_exec("sudo echo \"".$cmd."\" > /tmp/unshift.sh && sudo chmod +x /tmp/unshift.sh"); - shell_exec("sudo /tmp/unshift.sh"); - shell_exec("sudo rm -f /tmp/unshift.sh"); + $cmd = "sudo rm -f " . $shifted_path.$filename; + shell_exec($cmd); } echo "OK"; From a65d07083778ae6f67690c627494058dc1d5b98a Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:04:16 -0400 Subject: [PATCH 04/17] Apprise exclude these species instead of include --- scripts/config.php | 2 +- scripts/utils/notifications.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index fc76879..d320313 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -542,7 +542,7 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}

- +

diff --git a/scripts/utils/notifications.py b/scripts/utils/notifications.py index 7db08d4..2ef9251 100644 --- a/scripts/utils/notifications.py +++ b/scripts/utils/notifications.py @@ -49,7 +49,7 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu APPRISE_ONLY_NOTIFY_SPECIES_NAMES = settings_dict.get('APPRISE_ONLY_NOTIFY_SPECIES_NAMES') if APPRISE_ONLY_NOTIFY_SPECIES_NAMES is not None and APPRISE_ONLY_NOTIFY_SPECIES_NAMES.strip() != "": - if not any(bird.lower().replace(" ", "") in comName.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES.split(",")): + if any(bird.lower().replace(" ", "") in comName.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES.split(",")): return APPRISE_MINIMUM_SECONDS_BETWEEN_NOTIFICATIONS_PER_SPECIES = settings_dict.get('APPRISE_MINIMUM_SECONDS_BETWEEN_NOTIFICATIONS_PER_SPECIES') From 9309e23c3f31dd53089e6b7840156aec3fba9350 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 22 Mar 2023 13:14:54 -0400 Subject: [PATCH 05/17] Change how perms are given for txt files --- scripts/update_birdnet_snippets.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index e04c080..d31d91a 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -11,11 +11,7 @@ my_dir=$HOME/BirdNET-Pi/scripts #sudo chmod -R g+wr $HOME/* find $HOME/* -not -user $USER -execdir sudo -E chown $USER:$USER {} \+ find $HOME/* -not -user $USER -execdir sudo chmod g+wr {} \+ -files=("$HOME/BirdNET-Pi/apprise.txt" "$HOME/BirdNET-Pi/exclude_species_list.txt" "$HOME/BirdNET-Pi/include_species_list.txt" "$HOME/BirdNET-Pi/scripts/disk_check_exclude.txt" "$HOME/BirdNET-Pi/scripts/blacklisted_images.txt") -for file in "${files[@]}" -do - sudo chown caddy:caddy "$file" -done +chmod 666 ~/BirdNET-Pi/scripts/*.txt chmod -R a+w $HOME/BirdNET-Pi/scripts/*.php # Create blank sitename as it's optional. First time install will use $HOSTNAME. From 5dec3cb76afc460a8b800f448617927086d843e2 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 22 Mar 2023 13:22:14 -0400 Subject: [PATCH 06/17] Flickr new policy compliance, user agents are now required --- scripts/overview.php | 1 + scripts/stats.php | 1 + scripts/todays_detections.php | 1 + scripts/utils/notifications.py | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/overview.php b/scripts/overview.php index c2f62bd..56cf40b 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -2,6 +2,7 @@ error_reporting(E_ERROR); ini_set('display_errors',1); ini_set('session.gc_maxlifetime', 7200); +ini_set('user_agent', 'PHP_Flickr/1.0'); session_set_cookie_params(7200); session_start(); $myDate = date('Y-m-d'); diff --git a/scripts/stats.php b/scripts/stats.php index 8a47cba..9b6da18 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -1,4 +1,5 @@ Date: Thu, 23 Mar 2023 11:43:18 -0400 Subject: [PATCH 07/17] hopefully these perms work --- scripts/update_birdnet_snippets.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index d31d91a..8114da5 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -12,6 +12,7 @@ my_dir=$HOME/BirdNET-Pi/scripts find $HOME/* -not -user $USER -execdir sudo -E chown $USER:$USER {} \+ find $HOME/* -not -user $USER -execdir sudo chmod g+wr {} \+ chmod 666 ~/BirdNET-Pi/scripts/*.txt +chmod 666 ~/BirdNET-Pi/*.txt chmod -R a+w $HOME/BirdNET-Pi/scripts/*.php # Create blank sitename as it's optional. First time install will use $HOSTNAME. From cff6e9ae17b34b1d46f4385bbde49aaffd861cfd Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:51:10 -0400 Subject: [PATCH 08/17] Fix custom image displaying when its not set Co-Authored-By: lloydbayley <21309308+lloydbayley@users.noreply.github.com> --- scripts/overview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/overview.php b/scripts/overview.php index 56cf40b..3246012 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -461,7 +461,7 @@ window.setInterval(function(){ document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now(); }, *1000); - + 2){?> // every 1 second, this loop will run and refresh the custom image window.setInterval(function(){ // Find the customimage element From 1b2f3e16b36e20edd2e6555574cad19eecd025d6 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Fri, 24 Mar 2023 13:41:34 -0400 Subject: [PATCH 09/17] Backlog clarification --- scripts/overview.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/overview.php b/scripts/overview.php index 3246012..6c324a3 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -24,6 +24,14 @@ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); +$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\', \'localtime\')'); +if($statement2 == False) { + echo "Database is busy"; + header("refresh: 0;"); +} +$result2 = $statement2->execute(); +$todaycount = $result2->fetchArray(SQLITE3_ASSOC); + if(isset($_GET['custom_image'])){ if(isset($config["CUSTOM_IMAGE"])) { ?> @@ -216,7 +224,11 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse } } if($iterations == 0) { - echo "

No Detections For Today.

"; + if($todaycount > 0) { + echo "

Your system is currently processing a backlog of audio. This can take several hours before normal functionality of your BirdNET-Pi resumes.

"; + } else { + echo "

No Detections For Today.

"; + } } die(); } @@ -231,14 +243,6 @@ if($statement == False) { $result = $statement->execute(); $totalcount = $result->fetchArray(SQLITE3_ASSOC); -$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\', \'localtime\')'); -if($statement2 == False) { - echo "Database is busy"; - header("refresh: 0;"); -} -$result2 = $statement2->execute(); -$todaycount = $result2->fetchArray(SQLITE3_ASSOC); - $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"; From af8e7d433f82b350a3061d139956c76aa5be5776 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Fri, 24 Mar 2023 14:46:48 -0400 Subject: [PATCH 10/17] clarifying some language --- scripts/overview.php | 2 +- scripts/todays_detections.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/overview.php b/scripts/overview.php index 6c324a3..d6f8567 100644 --- a/scripts/overview.php +++ b/scripts/overview.php @@ -314,7 +314,7 @@ body::-webkit-scrollbar {

- + diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index c08ba5c..d81653a 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -406,7 +406,7 @@ die();

- + From 2a1d1693fe752da5618ff1a3d24971a8802e10b3 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 27 Mar 2023 16:03:25 -0400 Subject: [PATCH 11/17] Fixing time display issues --- scripts/config.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index d320313..ee92207 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -639,8 +639,11 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}

Time and Date

If connected to the internet, retrieve time automatically? >
- > - >
+ + > + >