tweaking a few fixes

This commit is contained in:
Patrick McGuire
2021-09-30 12:07:47 -04:00
parent ec57bdaf83
commit c2bb057999
3 changed files with 21 additions and 15 deletions
+2 -4
View File
@@ -4,8 +4,6 @@
source /etc/birdnet/birdnet.conf source /etc/birdnet/birdnet.conf
CUSTOM_LIST="/home/pi/BirdNET-Lite/custom_species_list.txt" CUSTOM_LIST="/home/pi/BirdNET-Lite/custom_species_list.txt"
DAYS=( DAYS=(
"2 days ago"
"yesterday"
"today" "today"
) )
@@ -33,8 +31,8 @@ move_analyzed() {
mkdir -vvvvvvvp "${1}-Analyzed" && echo "'Analyzed' directory created" mkdir -vvvvvvvp "${1}-Analyzed" && echo "'Analyzed' directory created"
fi fi
echo "Moving analyzed files to new directory" echo "Moving analyzed files to new directory"
mv -vv "${1}/${i}" "${1}-Analyzed/" mv "${1}/${i}" "${1}-Analyzed/"
mv -vv "${1}/${j}" "${1}-Analyzed/" mv "${1}/${j}" "${1}-Analyzed/"
fi fi
done done
} }
+7 -1
View File
@@ -23,14 +23,20 @@ else
a=0 a=0
fi fi
echo echo
SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2)) if [ "${a}" -ge "1" ];then
SOFAR=$(($(wc -l ${IDFILE}| cut -d' ' -f1)/2))
else
SOFAR=0
fi
echo " -$a detections so far" echo " -$a detections so far"
echo echo
echo " -$SOFAR species identified so far" echo " -$SOFAR species identified so far"
echo echo
if [ ${a} -ge 1 ];then
while read -r line;do while read -r line;do
echo " | $line" echo " | $line"
done < <(awk -v n=2 '1; NR % n == 0 {print ""}' ${IDFILE}) done < <(awk -v n=2 '1; NR % n == 0 {print ""}' ${IDFILE})
fi
echo echo
echo -n "Listening since "${INSTALL_DATE}"" echo -n "Listening since "${INSTALL_DATE}""
sleep 180 sleep 180
+12 -10
View File
@@ -34,7 +34,6 @@ fi
echo "Starting numbering at ${a}" echo "Starting numbering at ${a}"
for h in "${SCAN_DIRS[@]}";do for h in "${SCAN_DIRS[@]}";do
echo "Creating the TMPFILE"
# The TMPFILE is created from each .csv file BirdNET creates # The TMPFILE is created from each .csv file BirdNET creates
# within each "Analyzed" directory # within each "Analyzed" directory
# Field 1: Start (s) # Field 1: Start (s)
@@ -42,6 +41,14 @@ for h in "${SCAN_DIRS[@]}";do
# Field 3: Scientific name # Field 3: Scientific name
# Field 4: Common name # Field 4: Common name
# Field 5: Confidence # Field 5: Confidence
# Removes old directories
if echo "${h}" | grep $(date --date="yesterday" "+%A") &> /dev/null;then
echo "Removing old directories"
rm -df "${h}"
rm -df "$(echo ${h} | cut -d'-' -f1-3)"
continue
fi
# Iterates over each "Analyzed" directory # Iterates over each "Analyzed" directory
for i in $(find ${h} -name '*csv' | sort );do for i in $(find ${h} -name '*csv' | sort );do
# Iterates over each '.csv' file found in each "Analyzed" directory # Iterates over each '.csv' file found in each "Analyzed" directory
@@ -87,24 +94,20 @@ for h in "${SCAN_DIRS[@]}";do
fi fi
echo "Checking for ${h}/${OLDFILE}"
# Before extracting the "Selection," the script checks to be sure the # Before extracting the "Selection," the script checks to be sure the
# original WAVE file still exists. # original WAVE file still exists.
[[ -f "${h}/${OLDFILE}" ]] || continue [[ -f "${h}/${OLDFILE}" ]] || continue
echo "Checking for ${NEWSPECIES_BYDATE}"
# If a directory does not already exist for the species (by date), # If a directory does not already exist for the species (by date),
# it is created # it is created
[[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}" [[ -d "${NEWSPECIES_BYDATE}" ]] || mkdir -p "${NEWSPECIES_BYDATE}"
echo "Checking for ${NEWSPECIES_BY_COMMON}"
# If a directory does not already exist for the species (by-species), # If a directory does not already exist for the species (by-species),
# it is created. # it is created.
[[ -d "${NEWSPECIES_BY_COMMON}" ]] || mkdir -p "${NEWSPECIES_BY_COMMON}" [[ -d "${NEWSPECIES_BY_COMMON}" ]] || mkdir -p "${NEWSPECIES_BY_COMMON}"
echo "Checking for ${NEWSPECIES_BY_SCIENCE}"
# If a directory does not already exist for the species (by-species), # If a directory does not already exist for the species (by-species),
# it is created. # it is created.
[[ -d "${NEWSPECIES_BY_SCIENCE}" ]] || mkdir -p "${NEWSPECIES_BY_SCIENCE}" [[ -d "${NEWSPECIES_BY_SCIENCE}" ]] || mkdir -p "${NEWSPECIES_BY_SCIENCE}"
@@ -124,7 +127,7 @@ for h in "${SCAN_DIRS[@]}";do
# structured by-species, symbolic links are made to populate the new # structured by-species, symbolic links are made to populate the new
# directory. # directory.
ffmpeg -hide_banner -loglevel 52 -nostdin -i "${h}/${OLDFILE}" \ ffmpeg -hide_banner -loglevel error -nostdin -i "${h}/${OLDFILE}" \
-acodec copy -ss "${START}" -to "${END}"\ -acodec copy -ss "${START}" -to "${END}"\
"${NEWSPECIES_BYDATE}/${a}-${NEWFILE}" "${NEWSPECIES_BYDATE}/${a}-${NEWFILE}"
if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 21 ]];then if [[ "$(find ${NEWSPECIES_BY_COMMON} | wc -l)" -ge 21 ]];then
@@ -158,7 +161,7 @@ for h in "${SCAN_DIRS[@]}";do
done < "${TMPFILE}" done < "${TMPFILE}"
echo -e "\n\n\nFINISHED!!! Processed extractions for ${h}" echo -e "\n\n\nFINISHED!!! Processed extractions for ${h:19}"
# Once each line of the TMPFILE has been processed, the TMPFILE is emptied # Once each line of the TMPFILE has been processed, the TMPFILE is emptied
# for the next iteration of the for loop. # for the next iteration of the for loop.
>"${TMPFILE}" >"${TMPFILE}"
@@ -167,7 +170,7 @@ for h in "${SCAN_DIRS[@]}";do
# next extraction. # next extraction.
[[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}" [[ -d "${PROCESSED}" ]] || mkdir "${PROCESSED}"
echo "Moving processed files to ${PROCESSED}" echo "Moving processed files to ${PROCESSED}"
mv -v ${h}/* ${PROCESSED} || continue mv ${h}/* ${PROCESSED} &> /dev/null || continue
done done
echo "Linking Processed files to "${EXTRACTED}/Processed" web directory" echo "Linking Processed files to "${EXTRACTED}/Processed" web directory"
@@ -180,5 +183,4 @@ fi
# That's all! # That's all!
echo "Finished -- the extracted sections are in: echo "Finished -- the extracted sections are in ${EXTRACTED}"
$(find -L ${EXTRACTED} -maxdepth 1)"