From 4d4fea0f998f8cfcd3b9b22a64965b903f6c82de Mon Sep 17 00:00:00 2001 From: frederik Date: Sun, 24 Apr 2022 11:28:40 +0200 Subject: [PATCH 01/45] add permanent fix for midnight bug --- scripts/extract_new_birdsounds.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index cee339a..754e218 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -27,12 +27,12 @@ for h in "${SCAN_DIRS[@]}";do # Field 5: Confidence # Removes old directories - #if echo "${h}" | grep $(date --date="yesterday" "+%A") &> /dev/null;then - # echo "Removing old directories" - # rm -drf "${h}" - # rm -drf "$(echo ${h} | cut -d'-' -f1-3)" - # continue - #fi + if echo "${h}" | grep $(date --date="-2 day" "+%A") &> /dev/null;then + echo "Removing old directories" + rm -drf "${h}" + rm -drf "$(echo ${h} | cut -d'-' -f1-3)" + continue + fi # Iterates over each "Analyzed" directory for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do From f1ebae64586d23a6a8578489f394c0222ca1403d Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:33:32 -0400 Subject: [PATCH 02/45] rtsp adjustments --- scripts/birdnet_recording.sh | 39 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 0798511..68405c5 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -2,29 +2,28 @@ set -x source /etc/birdnet/birdnet.conf -if [ "${TIMESTAMP_FORMAT}" == "12" ];then - STAMP="%I:%M:%S%P" -else - STAMP="%H:%M:%S" -fi +STAMP="%H:%M:%S" [ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15 -if ! pulseaudio --check;then pulseaudio --start;fi - -if pgrep arecord &> /dev/null ;then - echo "Recording" -else - until grep 5050 <(netstat -tulpn 2>&1);do - sleep 1 +if [ ! -z $RTSP_STREAM ];then + while true;do + ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$STAMP.wav done - if [ -z ${REC_CARD} ];then - - arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ - --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav +else + if ! pulseaudio --check;then pulseaudio --start;fi + if pgrep arecord &> /dev/null ;then + echo "Recording" else - arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ - -D "${REC_CARD}" --use-strftime \ - ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav - fi + until grep 5050 <(netstat -tulpn 2>&1);do + sleep 1 + done + if [ -z ${REC_CARD} ];then + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ + --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + else + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ + -D "${REC_CARD}" --use-strftime \ + ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + fi fi From bc9edb8eb1980754189cc20287aadc4d00b0664d Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:54:46 -0400 Subject: [PATCH 03/45] adding RTSP_STREAM variable --- birdnet.conf-defaults | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index 5863aab..f21fcad 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -48,6 +48,13 @@ ICE_PWD=birdnetpi BIRDNETPI_URL= +#---------------------------- RTSP Stream URL -------------------------------# + +## If RTSP_STREAM is set, the system will use the RTSP stream as its audio +## source instead of recording its own audio. If this variable is kept empty, +## BirdNET-Pi will default to recording its own audio. + +RTSP_STREAM= #------------------- Mobile Notifications via Pushed.co ---------------------# #____________The two variables below enable mobile notifications_______________# From 0cc8c3491a6c6c903685e4bb9349b0c94f813b2e Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:55:34 -0400 Subject: [PATCH 04/45] Update install_config.sh --- scripts/install_config.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/install_config.sh b/scripts/install_config.sh index cbd29f1..8906ec5 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -61,6 +61,13 @@ ICE_PWD=birdnetpi BIRDNETPI_URL= +#---------------------------- RTSP Stream URL -------------------------------# + +## If RTSP_STREAM is set, the system will use the RTSP stream as its audio +## source instead of recording its own audio. If this variable is kept empty, +## BirdNET-Pi will default to recording its own audio. + +RTSP_STREAM= #------------------- Mobile Notifications via Pushed.co ---------------------# #____________The two variables below enable mobile notifications_______________# From 737042b24b3e2d9f76975ce58708711776584bfe Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:57:34 -0400 Subject: [PATCH 05/45] Update update_birdnet.sh adding the new variable to the update script to make sure it is added to older systems --- scripts/update_birdnet.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/update_birdnet.sh b/scripts/update_birdnet.sh index a48e7d6..dd6e84a 100755 --- a/scripts/update_birdnet.sh +++ b/scripts/update_birdnet.sh @@ -18,3 +18,6 @@ fi if ! grep PRIVACY_MODE /etc/birdnet/birdnet.conf;then sudo -u${USER} echo "PRIVACY_MODE=off" >> /etc/birdnet/birdnet.conf fi +if ! grep RTSP_STREAM /etc/birdnet/birdnet.conf;then + sudo -u${USER} echo "RTSP_STREAM=" >> /etc/birdnet/birdnet.conf +fi From ce782c4b8350ba9c2925331e19820b48dc14e808 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Mon, 25 Apr 2022 09:11:25 -0400 Subject: [PATCH 06/45] Update advanced.php --- scripts/advanced.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/advanced.php b/scripts/advanced.php index a4da847..4a60f71 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -64,6 +64,19 @@ if(isset($_GET['submit'])) { } } + if(isset($_GET["rtsp_stream"])) { + $rtsp_stream = $_GET["rtsp_stream"]; + if(strcmp($rtsp_stream,$config['RTSP_STREAM']) !== 0) { + $contents = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents); + $contents2 = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents2); + $fh = fopen('/etc/birdnet/birdnet.conf', "w"); + $fh2 = fopen("./scripts/thisrun.txt", "w"); + fwrite($fh, $contents); + fwrite($fh2, $contents2); + exec('sudo systemctl restart birdnet_recording.service'); + } + } + if(isset($_GET["overlap"])) { $overlap = $_GET["overlap"]; if(strcmp($overlap,$config['OVERLAP']) !== 0) { @@ -201,6 +214,9 @@ if (file_exists('./scripts/thisrun.txt')) {

Set Channels to the number of channels supported by your sound card. 32 max.

+ +
+

If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source.


Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.

From 6f8e676f4e4b87846c0d0b17ed7085c8ac42f96b Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Mon, 25 Apr 2022 09:29:43 -0400 Subject: [PATCH 07/45] missing fi --- scripts/birdnet_recording.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 68405c5..0798a5a 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -26,4 +26,5 @@ else -D "${REC_CARD}" --use-strftime \ ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav fi + fi fi From 5b6d36ba0e970063722ea697f5c3ac35e675dca9 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Mon, 25 Apr 2022 09:31:40 -0400 Subject: [PATCH 08/45] remove STAMP just use `date` --- scripts/birdnet_recording.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 0798a5a..e2ea480 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -2,13 +2,11 @@ set -x source /etc/birdnet/birdnet.conf -STAMP="%H:%M:%S" - [ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15 if [ ! -z $RTSP_STREAM ];then while true;do - ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$STAMP.wav + ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav done else if ! pulseaudio --check;then pulseaudio --start;fi @@ -20,11 +18,11 @@ else done if [ -z ${REC_CARD} ];then arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ - --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-$(date "+%F").wav else arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ -D "${REC_CARD}" --use-strftime \ - ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-$(date "+%F").wav fi fi fi From 70d08ccf14c63cc4d254b989516728fc8910bd86 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Mon, 25 Apr 2022 09:39:21 -0400 Subject: [PATCH 09/45] adjustments to read from rtsp --- scripts/extract_new_birdsounds.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index cee339a..482c37b 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -13,9 +13,9 @@ source /etc/birdnet/birdnet.conf # Set Variables TMPFILE=$(mktemp) -ANALYZED=${RECS_DIR}/*/*Analyzed -# SCAN_DIRS are all directories marked "Analyzed" -SCAN_DIRS=($(find ${ANALYZED} -type d 2>/dev/null | sort )) +#ANALYZED=${RECS_DIR}/*/*Analyzed +#SCAN_DIRS are all directories marked "Analyzed" +SCAN_DIRS=($(find $HOME -type d -name '*Analyzed' 2>/dev/null | sort )) for h in "${SCAN_DIRS[@]}";do # The TMPFILE is created from each .csv file BirdNET creates @@ -38,13 +38,14 @@ for h in "${SCAN_DIRS[@]}";do for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do # Iterates over each '.csv' file found in each "Analyzed" directory # to create the TMPFILE - echo "${i}" | cut -d'/' -f7 >> ${TMPFILE} + echo "$(basename ${i})" >> ${TMPFILE} sort -k1n -t\; "${i}" | awk '!/Start/{print}' >> ${TMPFILE} done # The extraction reads each line of the TMPFILE and sets the variables ffmpeg # will use. while read -r line;do + echo "Line = $line" DATE="$(echo "${line}" \ | awk -F- '/birdnet/{print $1"-"$2"-"$3}')" if [ ! -z ${DATE} ];then From 7c687e5eb26f09ab0c0a1c3a10baa6f99087c6b2 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Mon, 25 Apr 2022 10:19:01 -0400 Subject: [PATCH 10/45] I dont' know how I messed up the first versions so badly, but this one is working --- scripts/birdnet_recording.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index e2ea480..1f1cd8d 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -18,11 +18,11 @@ else done if [ -z ${REC_CARD} ];then arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ - --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-$(date "+%F").wav + --use-strftime ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav else arecord -f S16_LE -c${CHANNELS} -r48000 -t wav --max-file-time ${RECORDING_LENGTH}\ -D "${REC_CARD}" --use-strftime \ - ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-$(date "+%F").wav + ${RECS_DIR}/%B-%Y/%d-%A/%F-birdnet-%H:%M:%S.wav fi fi fi From ff9f3552712c4fbb0066789eebd7555116a7bb3e Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 25 Apr 2022 10:24:23 -0400 Subject: [PATCH 11/45] Update livestream.sh --- scripts/livestream.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/livestream.sh b/scripts/livestream.sh index bdebba7..d081d53 100755 --- a/scripts/livestream.sh +++ b/scripts/livestream.sh @@ -4,8 +4,12 @@ source /etc/birdnet/birdnet.conf if [ -z ${REC_CARD} ];then echo "Stream not supported" -else - ffmpeg -loglevel 52 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \ +elif [[ ! -z ${RTSP_STREAM} ]];then + ffmpeg -loglevel 52 -ac ${CHANNELS} -i ${RTSP_STREAM} -acodec libmp3lame \ -b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \ -f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re -fi +else + ffmpeg -loglevel 52 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \ + -b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \ + -f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re +fi \ No newline at end of file From 2ca8fb203bffcd7cad37ce0c6587f43c179c0eae Mon Sep 17 00:00:00 2001 From: frederik Date: Sun, 24 Apr 2022 18:21:10 +0200 Subject: [PATCH 12/45] move deleting of old directories to end of processing to minimize the chance we delete unprocessed files --- scripts/extract_new_birdsounds.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index 754e218..947802b 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -26,14 +26,6 @@ for h in "${SCAN_DIRS[@]}";do # Field 4: Common name # Field 5: Confidence - # Removes old directories - if echo "${h}" | grep $(date --date="-2 day" "+%A") &> /dev/null;then - echo "Removing old directories" - rm -drf "${h}" - rm -drf "$(echo ${h} | cut -d'-' -f1-3)" - continue - fi - # Iterates over each "Analyzed" directory for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do # Iterates over each '.csv' file found in each "Analyzed" directory @@ -142,7 +134,14 @@ for h in "${SCAN_DIRS[@]}";do # next extraction. [[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}" #echo "Moving processed files to ${PROCESSED}" - mv ${h}/* ${PROCESSED} &> /dev/null || continue + mv ${h}/* ${PROCESSED} &> /dev/null || true + + # Removes old directories + if echo "${h}" | grep $(date --date="-2 day" "+%A") &> /dev/null;then + echo "Removing old directories" + rm -drf "${h}" + rm -drf "$(echo ${h} | cut -d'-' -f1-3)" + fi done #echo "Linking Processed files to "${EXTRACTED}/Processed" web directory" From 256b405c214be6ee7fdeeb6097018a5eb7b041bf Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 25 Apr 2022 16:51:04 -0400 Subject: [PATCH 13/45] Allowing multiple RTSP stream urls (untested) --- scripts/advanced.php | 18 +++++++++--------- scripts/birdnet_recording.sh | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/advanced.php b/scripts/advanced.php index 4a60f71..204dd0a 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -65,7 +65,7 @@ if(isset($_GET['submit'])) { } if(isset($_GET["rtsp_stream"])) { - $rtsp_stream = $_GET["rtsp_stream"]; + $rtsp_stream = str_replace("\r\n", ",", $_GET["rtsp_stream"]); if(strcmp($rtsp_stream,$config['RTSP_STREAM']) !== 0) { $contents = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents); $contents2 = preg_replace("/RTSP_STREAM=.*/", "RTSP_STREAM=$rtsp_stream", $contents2); @@ -76,7 +76,7 @@ if(isset($_GET['submit'])) { exec('sudo systemctl restart birdnet_recording.service'); } } - + if(isset($_GET["overlap"])) { $overlap = $_GET["overlap"]; if(strcmp($overlap,$config['OVERLAP']) !== 0) { @@ -121,14 +121,14 @@ if(isset($_GET['submit'])) { $contents2 = preg_replace("/PRIVACY_MODE=.*/", "PRIVACY_MODE=$privacy_mode", $contents2); if(strcmp($privacy_mode,"on") == 0) { exec('sudo sed -i \'s/\/usr\/local\/bin\/server.py/\/usr\/local\/bin\/privacy_server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service'); - exec('sudo systemctl daemon-reload'); - exec('restart_services.sh'); - header('Location: /log'); + exec('sudo systemctl daemon-reload'); + exec('restart_services.sh'); + header('Location: /log'); } elseif(strcmp($privacy_mode,"off") == 0) { exec('sudo sed -i \'s/\/usr\/local\/bin\/privacy_server.py/\/usr\/local\/bin\/server.py/g\' ../../BirdNET-Pi/templates/birdnet_server.service'); - exec('sudo systemctl daemon-reload'); - exec('restart_services.sh'); - header('Location: /log'); + exec('sudo systemctl daemon-reload'); + exec('restart_services.sh'); + header('Location: /log'); } } } @@ -215,7 +215,7 @@ if (file_exists('./scripts/thisrun.txt')) {

Set Channels to the number of channels supported by your sound card. 32 max.

-
+

If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source.


diff --git a/scripts/birdnet_recording.sh b/scripts/birdnet_recording.sh index 1f1cd8d..ccd1024 100755 --- a/scripts/birdnet_recording.sh +++ b/scripts/birdnet_recording.sh @@ -6,7 +6,9 @@ source /etc/birdnet/birdnet.conf if [ ! -z $RTSP_STREAM ];then while true;do - ffmpeg -i $RTSP_STREAM -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav + for i in ${RTSP_STREAM//,/ };do + ffmpeg -i ${i} -t 15 -vn -acodec pcm_s16le -ac 2 -ar 48000 file:${RECS_DIR}/$(date "+%F")-birdnet-$(date "+%H:%M:%S").wav /dev/null 2>&1 & sleep 1; + done done else if ! pulseaudio --check;then pulseaudio --start;fi From 8864bdf280f41ccbc353516f56d6d8d34c43386f Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 25 Apr 2022 16:53:30 -0400 Subject: [PATCH 14/45] Update advanced.php --- scripts/advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/advanced.php b/scripts/advanced.php index 204dd0a..b73bfbe 100644 --- a/scripts/advanced.php +++ b/scripts/advanced.php @@ -216,7 +216,7 @@ if (file_exists('./scripts/thisrun.txt')) {

Set Channels to the number of channels supported by your sound card. 32 max.


-

If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source.

+

If you place an RTSP stream URL here, BirdNET-Pi will use that as its audio source. If you have multiple streams, each URL should be on its own line.


Set Recording Length in seconds between 6 and 60. Multiples of 3 are recommended, as BirdNET analyzes in 3-second chunks.

From 4be35733893f2611bd05dbacecc87e600afe4755 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:10:41 -0400 Subject: [PATCH 15/45] Update views.php --- homepage/views.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index 55f2c75..cd04e71 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -186,10 +186,6 @@ if(isset($_GET['view'])){ } } elseif(isset($_GET['submit'])) { $command = $_GET['submit']; - if(isset($command)){ - $results = shell_exec("$command 2>&1"); - echo "
$results
"; - } ob_end_flush(); } else {include('overview.php');} ?> From a6d8f37f45edf75507c955eb33aacca7f01436b2 Mon Sep 17 00:00:00 2001 From: Patrick McGuire <60325264+mcguirepr89@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:39:14 -0400 Subject: [PATCH 16/45] Update views.php --- homepage/views.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/homepage/views.php b/homepage/views.php index cd04e71..942f6bf 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -185,7 +185,33 @@ if(isset($_GET['view'])){ } } } elseif(isset($_GET['submit'])) { - $command = $_GET['submit']; + if (file_exists('./scripts/thisrun.txt')) { + $config = parse_ini_file('./scripts/thisrun.txt'); + } elseif (file_exists('./scripts/firstrun.ini')) { + $config = parse_ini_file('./scripts/firstrun.ini'); + } + $caddypwd = $config['CADDY_PWD']; + if (!isset($_SERVER['PHP_AUTH_USER'])) { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot access the web terminal'; + exit; + } else { + $submittedpwd = $_SERVER['PHP_AUTH_PW']; + $submitteduser = $_SERVER['PHP_AUTH_USER']; + if($submittedpwd == $caddypwd && $submitteduser == 'birdnet'){ + $command = $_GET['submit']; + if(isset($command)){ + $results = shell_exec("$command 2>&1"); + echo "
$results
"; + } else { + header('WWW-Authenticate: Basic realm="My Realm"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'You cannot access the web terminal'; + exit; + } + } + } ob_end_flush(); } else {include('overview.php');} ?> From c62a911518efce794476d5eb27b2eb065ab427cd Mon Sep 17 00:00:00 2001 From: African Penguin Date: Sun, 1 May 2022 10:15:50 +0200 Subject: [PATCH 17/45] Revert "Fix/midnightbug" --- scripts/extract_new_birdsounds.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/extract_new_birdsounds.sh b/scripts/extract_new_birdsounds.sh index 947802b..cee339a 100755 --- a/scripts/extract_new_birdsounds.sh +++ b/scripts/extract_new_birdsounds.sh @@ -26,6 +26,14 @@ for h in "${SCAN_DIRS[@]}";do # Field 4: Common name # Field 5: Confidence + # Removes old directories + #if echo "${h}" | grep $(date --date="yesterday" "+%A") &> /dev/null;then + # echo "Removing old directories" + # rm -drf "${h}" + # rm -drf "$(echo ${h} | cut -d'-' -f1-3)" + # continue + #fi + # Iterates over each "Analyzed" directory for i in $(find ${h} -name '*csv' 2>/dev/null | sort );do # Iterates over each '.csv' file found in each "Analyzed" directory @@ -134,14 +142,7 @@ for h in "${SCAN_DIRS[@]}";do # next extraction. [[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}" #echo "Moving processed files to ${PROCESSED}" - mv ${h}/* ${PROCESSED} &> /dev/null || true - - # Removes old directories - if echo "${h}" | grep $(date --date="-2 day" "+%A") &> /dev/null;then - echo "Removing old directories" - rm -drf "${h}" - rm -drf "$(echo ${h} | cut -d'-' -f1-3)" - fi + mv ${h}/* ${PROCESSED} &> /dev/null || continue done #echo "Linking Processed files to "${EXTRACTED}/Processed" web directory" From 746867c67717e650da1d5b83ab8ffdc17f8e3b22 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Sun, 1 May 2022 10:57:22 -0400 Subject: [PATCH 18/45] Adding search to Today's Detections --- scripts/todays_detections.php | 42 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index 2f25575..475e000 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -58,11 +58,16 @@ $result6 = $statement6->execute(); $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC); if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) { + if(isset($_GET['searchterm'])) { + $searchquery = "AND (Com_name LIKE '%".$_GET['searchterm']."%' OR Sci_name LIKE '%".$_GET['searchterm']."%' OR Confidence LIKE '%".$_GET['searchterm']."%' OR File_Name LIKE '%".$_GET['searchterm']."%' OR Time LIKE '%".$_GET['searchterm']."%')"; + } else { + $searchquery = ""; + } if(isset($_GET['display_limit']) && is_numeric($_GET['display_limit'])){ - $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC LIMIT '.(intval($_GET['display_limit'])-40).',40'); + $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC LIMIT '.(intval($_GET['display_limit'])-40).',40'); } else { // legacy mode - $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC '); + $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC'.$searchquery); } if($statement0 == False){ echo "Database is busy"; @@ -151,7 +156,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) { -

Today's Detections

+

Today's Detections —

@@ -160,6 +165,22 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {