diff --git a/homepage/views.php b/homepage/views.php index 797e47c..1aba183 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -37,7 +37,7 @@ if(isset($_POST['view'])){ if($_POST['view'] == "Services"){include('scripts/service_controls.php');} if($_POST['view'] == "Spectrogram"){include('spectrogram.php');} if($_POST['view'] == "Overview"){include('overview.php');} - if($_POST['view'] == "Today's Detections"){include('viewdb.php');} + if($_POST['view'] == "Today's Detections"){include('todays_detections.php');} if($_POST['view'] == "Species Stats"){echo "

";include('stats.php');} if($_POST['view'] == "Daily Charts"){include('history.php');} if($_POST['view'] == "Tools"){ diff --git a/scripts/custom_recording.sh b/scripts/custom_recording.sh new file mode 100755 index 0000000..ccf4303 --- /dev/null +++ b/scripts/custom_recording.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +set -x +source /etc/birdnet/birdnet.conf + +STAMP="%H:%M:%S" + +[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15 + +if ! pulseaudio --check;then pulseaudio --start;fi + +CUSTOM_WINDOW_START=(0 3 15 22) +CUSTOM_WINDOW_END=(0 7 19 23) +RECORDING_DURATION=60 +PAUSE_DURATION=240 + +now=$(date +%H) + +while [ $now -ge ${CUSTOM_WINDOW_START[0]} ] && [ $now -le ${CUSTOM_WINDOW_END[0]} ];do + echo $now + # If you prefer no directory structure under "Raw", comment out the + # lines below and uncommend the commands at the bottom. + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + + # Uncomment the lines below if you'd prefer having no directory scructure + # under the "Raw" directory. Be sure to comment out the command above. + #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav + sleep $PAUSE_DURATION + now=$(date +%H) +done +while [ $now -ge ${CUSTOM_WINDOW_START[1]} ] && [ $now -le ${CUSTOM_WINDOW_END[1]} ];do + echo $now + # If you prefer no directory structure under "Raw", comment out the + # lines below and uncommend the commands at the bottom. + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + + # Uncomment the lines below if you'd prefer having no directory scructure + # under the "Raw" directory. Be sure to comment out the command above. + #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav + sleep $PAUSE_DURATION + now=$(date +%H) +done +while [ $now -ge ${CUSTOM_WINDOW_START[2]} ] && [ $now -le ${CUSTOM_WINDOW_END[2]} ];do + echo $now + # If you prefer no directory structure under "Raw", comment out the + # lines below and uncommend the commands at the bottom. + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + + # Uncomment the lines below if you'd prefer having no directory scructure + # under the "Raw" directory. Be sure to comment out the command above. + #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav + sleep $PAUSE_DURATION + now=$(date +%H) +done +while [ $now -ge ${CUSTOM_WINDOW_START[3]} ] && [ $now -le ${CUSTOM_WINDOW_END[3]} ];do + echo $now + # If you prefer no directory structure under "Raw", comment out the + # lines below and uncommend the commands at the bottom. + arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + --use-strftime ${EXTRACTED}/Raw/%B-%Y/%d-%A/%F-birdnet-${STAMP}.wav + + # Uncomment the lines below if you'd prefer having no directory scructure + # under the "Raw" directory. Be sure to comment out the command above. + #arecord -f S16_LE -c${CHANNELS} -r48000 -t wav -d $RECORDING_DURATION \ + # --use-strftime ${EXTRACTED}/Raw/%F-birdnet-${STAMP}.wav + sleep $PAUSE_DURATION + now=$(date +%H) +done + + diff --git a/scripts/install_services.sh b/scripts/install_services.sh index 58c5c31..297fb51 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -176,6 +176,24 @@ EOF systemctl enable birdnet_recording.service } +install_custom_recording_service() { + echo "Installing custom_recording.service" + cat << EOF > /home/pi/BirdNET-Pi/templates/custom_recording.service +[Unit] +Description=BirdNET Custom Recording +[Service] +Environment=XDG_RUNTIME_DIR=/run/user/1000 +Restart=always +Type=simple +RestartSec=3 +User=${USER} +ExecStart=/usr/local/bin/custom_recording.sh +[Install] +WantedBy=multi-user.target +EOF + ln -sf /home/pi/BirdNET-Pi/templates/birdnet_recording.service /usr/lib/systemd/system +} + install_Caddyfile() { [ -d /etc/caddy ] || mkdir /etc/caddy if [ -f /etc/caddy/Caddyfile ];then @@ -412,6 +430,7 @@ install_services() { install_birdnet_server install_birdnet_stats_service install_recording_service + install_custom_recording_service # But does not enable install_extraction_service install_pushed_notifications install_spectrogram_service diff --git a/scripts/viewdb.php b/scripts/todays_detections.php similarity index 93% rename from scripts/viewdb.php rename to scripts/todays_detections.php index e29e01f..dbdd8b9 100644 --- a/scripts/viewdb.php +++ b/scripts/todays_detections.php @@ -9,7 +9,7 @@ if($db == False){ header("refresh: 0;"); } -$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') GROUP BY Time ORDER BY Time DESC, MAX(Confidence) ASC'); +$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC'); if($statement0 == False){ echo "Database is busy"; header("refresh: 0;"); @@ -103,7 +103,7 @@ $sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);

Confidence:
- + ">