Merge pull request #836 from jaredb7/More-Misc-Fixes-and-Enhancements_mcguire

More misc fixes and enhancements
This commit is contained in:
ehpersonal38
2023-04-10 21:19:32 -04:00
committed by GitHub
10 changed files with 106 additions and 31 deletions
+26
View File
@@ -1,3 +1,29 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
.idea
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
*.pyc
*.flac
.vscode
+1 -1
View File
@@ -37,7 +37,7 @@ body::-webkit-scrollbar {
display:none
}
</style>
<link rel="stylesheet" href="style.css?v=4.06.23">
<link rel="stylesheet" href="style.css?v=<?php echo date ('n.d.y', filemtime('style.css')); ?>">
<link rel="stylesheet" type="text/css" href="static/dialog-polyfill.css" />
<body>
<div class="banner">
+6
View File
@@ -828,6 +828,12 @@ pre#timer.bash {
background-color: #9fe29b;
}
.exclude_species_list_option_highlight {
color: black;
background-color: rgb(119, 196, 135);
font-weight: bolder;
}
#ddnewline::before {
content: none;
}
+26 -7
View File
@@ -271,10 +271,10 @@ if(isset($_GET['view'])){
} else {
$submittedpwd = $_SERVER['PHP_AUTH_PW'];
$submitteduser = $_SERVER['PHP_AUTH_USER'];
$allowedCommands = array('sudo systemctl stop livestream.service && sudo /etc/init.d/icecast2 stop',
'sudo systemctl restart livestream.service && sudo /etc/init.d/icecast2 restart',
'sudo systemctl disable --now livestream.service && sudo systemctl disable icecast2 && sudo /etc/init.d/icecast2 stop',
'sudo systemctl enable icecast2 && sudo /etc/init.d/icecast2 start && sudo systemctl enable --now livestream.service',
$allowedCommands = array('sudo systemctl stop livestream.service && sudo systemctl stop icecast2.service',
'sudo systemctl restart livestream.service && sudo systemctl restart icecast2.service',
'sudo systemctl disable --now livestream.service && sudo systemctl disable icecast2 && sudo systemctl stop icecast2.service',
'sudo systemctl enable icecast2 && sudo systemctl start icecast2.service && sudo systemctl enable --now livestream.service',
'sudo systemctl stop web_terminal.service',
'sudo systemctl restart web_terminal.service',
'sudo systemctl disable --now web_terminal.service',
@@ -321,9 +321,28 @@ if(isset($_GET['view'])){
if($submittedpwd == $caddypwd && $submitteduser == 'birdnet' && in_array($command,$allowedCommands)){
if(isset($command)){
$initcommand = $command;
if (strpos($command, "systemctl") !== false) {
$tmp = explode(" ",trim($command));
$command .= "& sleep 3;sudo systemctl status ".end($tmp);
if (strpos($command, "systemctl") !== false) {
//If there more than one command to execute, processes then separately
//currently only livestream service uses multiple commands to interact with the required services
if (strpos($command, " && ") !== false) {
$separate_commands = explode("&&", trim($command));
$new_multiservice_status_command = "";
foreach ($separate_commands as $indiv_service_command) {
//explode the string by " " space so we can get each individual component of the command
//and eventually the service name at the end
$separate_command_tmp = explode(" ", trim($indiv_service_command));
//get the service names
$new_multiservice_status_command .= " " . trim(end($separate_command_tmp));
}
$service_names = $new_multiservice_status_command;
} else {
//only one service needs restarting so we only need to query the status of one service
$tmp = explode(" ", trim($command));
$service_names = end($tmp);
}
$command .= " & sleep 3;sudo systemctl status " . $service_names;
}
if($initcommand == "update_birdnet.sh") {
unset($_SESSION['behind']);
+1 -1
View File
@@ -189,7 +189,7 @@ TODAY="$RECS_DIR/$(date "+%B-%Y/%d-%A")"
if [ $(find ${YESTERDAY} -name '*wav' 2>/dev/null | wc -l) -gt 0 ];then
find $YESTERDAY -name '*wav' -type f -size 0 -delete
run_birdnet "${YESTERDAY}"
elif [ $(find ${TODAY} -name '*wav' | wc -l) -gt 0 ];then
elif [ $(find ${TODAY} -name '*wav' 2>/dev/null | wc -l) -gt 0 ];then
find $TODAY -name '*wav' -type f -size 0 -delete
run_birdnet "${TODAY}"
fi
+6 -3
View File
@@ -1,8 +1,11 @@
#!/usr/bin/env bash
# Performs the recording from the specified RSTP stream or soundcard
set -x
# Performs the recording from the specified RTSP stream or soundcard
#set -x
source /etc/birdnet/birdnet.conf
# Set the logging level
LOGGING_LEVEL='error'
[ -z $RECORDING_LENGTH ] && RECORDING_LENGTH=15
if [ ! -z $RTSP_STREAM ];then
@@ -33,7 +36,7 @@ if [ ! -z $RTSP_STREAM ];then
# Make sure were passing something valid to ffmpeg, ffmpeg will run interactive and control our look by waiting ${RECORDING_LENGTH} between loops
if [ -n "$FFMPEG_PARAMS" ];then
ffmpeg -nostdin $FFMPEG_PARAMS
ffmpeg -hide_banner -loglevel $LOGGING_LEVEL -nostdin $FFMPEG_PARAMS
fi
done
+14 -8
View File
@@ -7,6 +7,8 @@
<form action="" method="GET" id="add">
<h3>All Species Labels</h3>
<input autocomplete="off" size="18" type="text" placeholder="Search Species..." id="exclude_species_searchterm" name="exclude_species_searchterm">
<br>
<span>Once the desired species has been highlighted, select it and click ADD to have it excluded.</span>
<select name="species[]" id="species" multiple size="auto">
<option>Choose a species below to add to the Excluded Species List</option>
<?php
@@ -38,6 +40,7 @@
<div class="customlabels column3">
<form action="" method="GET" id="del">
<h3>Excluded Species List</h3>
<br><br>
<select name="species[]" id="value2" multiple size="auto">
<?php
$filename = './scripts/exclude_species_list.txt';
@@ -77,10 +80,10 @@
//Now look at the select list, loop over the options and try find part of the text in the option's name/text
var species_select_list = document.querySelector('select#species');
//if the search text differs from last time start the search from the begining of te list
//if the search text differs from last time start the search from the beginning of te list
if (search_text !== last_search_term) {
//Also unselect the last match
species_select_list[search_match_idx].removeAttribute('selected');
species_select_list[search_match_idx].removeAttribute('class');
search_match_idx = 1;
}
@@ -91,9 +94,9 @@
search_match_text = option_text.toLowerCase().includes(search_text)
//Check if the item is already selected, that could mean that user may be searching the same phrase
//again, we want to search further so let's unselect it and move to the next index
if (species_select_list[search_match_idx].getAttribute('selected') === true || species_select_list[search_match_idx].getAttribute('selected') === "true") {
species_select_list[search_match_idx].removeAttribute('selected');
if (species_select_list[search_match_idx].getAttribute('class') === "exclude_species_list_option_highlight") {
species_select_list[search_match_idx].removeAttribute('class');
// species_select_list[search_match_idx].removeAttribute('style');
//Go to the next item
i++
continue;
@@ -110,12 +113,15 @@
search_match_idx = i;
//Scroll into view and select it
species_select_list[search_match_idx].scrollIntoView();
species_select_list[search_match_idx].setAttribute('selected', true);
species_select_list[search_match_idx].scrollIntoView({behavior: 'smooth', block: 'start'});
//Apply a style to the option since setting the selected value to true breaks scrolling on chrome :(
//the style is nicer anyway :)
species_select_list[search_match_idx].setAttribute('class', "exclude_species_list_option_highlight");
// species_select_list[search_match_idx].setAttribute('selected', 'true');
//break the loop
break;
}
// }
}
//Track what search term was used so we know when to start over
last_search_term = search_text
+5 -2
View File
@@ -2,6 +2,9 @@
# Live Audio Stream Service Script
source /etc/birdnet/birdnet.conf
# Set logging level
LOGGING_LEVEL='error'
if [ -z ${REC_CARD} ];then
echo "Stream not supported"
elif [[ ! -z ${RTSP_STREAM} ]];then
@@ -22,11 +25,11 @@ elif [[ ! -z ${RTSP_STREAM} ]];then
SELECTED_RSTP_STREAM=${RSTP_STREAMS_EXPLODED_ARRAY[0]}
fi
ffmpeg -nostdin -loglevel 32 -ac ${CHANNELS} -i ${SELECTED_RSTP_STREAM} -acodec libmp3lame \
ffmpeg -nostdin -loglevel $LOGGING_LEVEL -ac ${CHANNELS} -i ${SELECTED_RSTP_STREAM} -acodec libmp3lame \
-b:a 320k -ac ${CHANNELS} -content_type 'audio/mpeg' \
-f mp3 icecast://source:${ICE_PWD}@localhost:8000/stream -re
else
ffmpeg -nostdin -loglevel 32 -ac ${CHANNELS} -f alsa -i ${REC_CARD} -acodec libmp3lame \
ffmpeg -nostdin -loglevel $LOGGING_LEVEL -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
+4 -4
View File
@@ -25,10 +25,10 @@ function service_status($name) {
<div class="servicecontrols">
<form action="" method="GET">
<h3>Live Audio Stream <?php echo service_status("livestream.service");?></h3>
<button type="submit" name="submit" value="sudo systemctl stop livestream.service && sudo /etc/init.d/icecast2 stop">Stop</button>
<button type="submit" name="submit" value="sudo systemctl restart livestream.service && sudo /etc/init.d/icecast2 restart">Restart </button>
<button type="submit" name="submit" value="sudo systemctl disable --now livestream.service && sudo systemctl disable icecast2 && sudo /etc/init.d/icecast2 stop">Disable</button>
<button type="submit" name="submit" value="sudo systemctl enable icecast2 && sudo /etc/init.d/icecast2 start && sudo systemctl enable --now livestream.service">Enable</button>
<button type="submit" name="submit" value="sudo systemctl stop livestream.service && sudo systemctl stop icecast2.service">Stop</button>
<button type="submit" name="submit" value="sudo systemctl restart livestream.service && sudo systemctl restart icecast2.service">Restart </button>
<button type="submit" name="submit" value="sudo systemctl disable --now livestream.service && sudo systemctl disable icecast2 && sudo systemctl stop icecast2.service">Disable</button>
<button type="submit" name="submit" value="sudo systemctl enable icecast2 && sudo systemctl start icecast2.service && sudo systemctl enable --now livestream.service">Enable</button>
</form>
<form action="" method="GET">
<h3>Web Terminal <?php echo service_status("web_terminal.service");?></h3>
+17 -5
View File
@@ -1,8 +1,20 @@
#!/usr/bin/env bash
# set -x
# Make sox spectrogram
source /etc/birdnet/birdnet.conf
analyzing_now="$(cat $HOME/BirdNET-Pi/analyzing_now.txt)"
if [ ! -z "${analyzing_now}" ] && [ -f "${analyzing_now}" ]; then
spectrogram_png=${EXTRACTED}/spectrogram.png
sox -V1 "${analyzing_now}" -n remix 1 rate 24k spectrogram -c "${analyzing_now//$HOME\/}" -o "${spectrogram_png}"
fi
# Time to sleep between generating spectrogram's, default set the recording length
# To try catch the spectrogram as soon as possible run at a smaller intervals
SLEEP_DELAY=$((RECORDING_LENGTH / 4))
# Continuously loop generating a spectrogram every 10 seconds
while true; do
analyzing_now="$(cat $HOME/BirdNET-Pi/analyzing_now.txt)"
if [ ! -z "${analyzing_now}" ] && [ -f "${analyzing_now}" ]; then
spectrogram_png=${EXTRACTED}/spectrogram.png
sox -V1 "${analyzing_now}" -n remix 1 rate 24k spectrogram -c "${analyzing_now//$HOME\//}" -o "${spectrogram_png}"
fi
sleep $SLEEP_DELAY
done