Merge branch 'mcguirepr89:main' into main
This commit is contained in:
@@ -101,7 +101,7 @@ if(isset($_GET['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["freqshift_hi"])) {
|
||||
if(isset($_GET["freqshift_hi"]) && is_numeric($_GET['freqshift_hi'])) {
|
||||
$freqshift_hi = $_GET["freqshift_hi"];
|
||||
if(strcmp($freqshift_hi,$config['FREQSHIFT_HI']) !== 0) {
|
||||
$contents = preg_replace("/FREQSHIFT_HI=.*/", "FREQSHIFT_HI=$freqshift_hi", $contents);
|
||||
@@ -109,7 +109,7 @@ if(isset($_GET['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["freqshift_lo"])) {
|
||||
if(isset($_GET["freqshift_lo"]) && is_numeric($_GET['freqshift_lo'])) {
|
||||
$freqshift_lo = $_GET["freqshift_lo"];
|
||||
if(strcmp($freqshift_lo,$config['FREQSHIFT_LO']) !== 0) {
|
||||
$contents = preg_replace("/FREQSHIFT_LO=.*/", "FREQSHIFT_LO=$freqshift_lo", $contents);
|
||||
@@ -117,7 +117,7 @@ if(isset($_GET['submit'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET["freqshift_pitch"])) {
|
||||
if(isset($_GET["freqshift_pitch"]) && is_numeric($_GET['freqshift_pitch'])) {
|
||||
$freqshift_pitch = $_GET["freqshift_pitch"];
|
||||
if(strcmp($freqshift_pitch,$config['FREQSHIFT_PITCH']) !== 0) {
|
||||
$contents = preg_replace("/FREQSHIFT_PITCH=.*/", "FREQSHIFT_PITCH=$freqshift_pitch", $contents);
|
||||
|
||||
+26
-29
@@ -76,7 +76,7 @@ if(isset($_GET["latitude"])){
|
||||
$apprise_weekly_report = 0;
|
||||
}
|
||||
|
||||
if(isset($timezone)) {
|
||||
if(isset($timezone) && in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||
shell_exec("sudo timedatectl set-timezone ".$timezone);
|
||||
date_default_timezone_set($timezone);
|
||||
echo "<script>setTimeout(
|
||||
@@ -92,7 +92,11 @@ if(isset($_GET["latitude"])){
|
||||
// can't set the date manually if it's getting it from the internet, disable ntp
|
||||
exec("sudo timedatectl set-ntp false");
|
||||
|
||||
exec("sudo date -s '".$_GET['date']." ".$_GET['time']."'");
|
||||
// check if valid date and time
|
||||
$datetime = DateTime::createFromFormat('Y-m-d H:i', $_GET['date'] . ' ' . $_GET['time']);
|
||||
if ($datetime && $datetime->format('Y-m-d H:i') === $_GET['date'] . ' ' . $_GET['time']) {
|
||||
exec("sudo date -s '".$_GET['date']." ".$_GET['time']."'");
|
||||
}
|
||||
} else {
|
||||
// user checked 'use time from internet if available,' so make sure that's on
|
||||
if(strlen(trim(exec("sudo timedatectl | grep \"NTP service: active\""))) == 0){
|
||||
@@ -107,34 +111,24 @@ 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);
|
||||
if ($model != $lang_config['MODEL'] || $language != $lang_config['DATABASE_LANG']){
|
||||
if(strlen($language) == 2){
|
||||
$user = trim(shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"));
|
||||
$home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"));
|
||||
|
||||
// Install new language label file
|
||||
syslog_shell_exec("$home/BirdNET-Pi/scripts/install_language_label.sh -l $language", $user);
|
||||
// Archive old language file
|
||||
syslog_shell_exec("cp -f $home/BirdNET-Pi/model/labels.txt $home/BirdNET-Pi/model/labels.txt.old", $user);
|
||||
|
||||
syslog(LOG_INFO, "Successfully changed language to '$language'");
|
||||
}
|
||||
if($model == "BirdNET_GLOBAL_3K_V2.2_Model_FP16"){
|
||||
// Install new language label file
|
||||
syslog_shell_exec("sudo chmod +x $home/BirdNET-Pi/scripts/install_language_label_nm.sh && $home/BirdNET-Pi/scripts/install_language_label_nm.sh -l $language", $user);
|
||||
} else {
|
||||
syslog_shell_exec("$home/BirdNET-Pi/scripts/install_language_label.sh -l $language", $user);
|
||||
}
|
||||
|
||||
if ($model != $lang_config['MODEL']){
|
||||
$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);
|
||||
|
||||
if($model == "BirdNET_GLOBAL_3K_V2.2_Model_FP16"){
|
||||
// Install new language label file
|
||||
syslog_shell_exec("sudo chmod +x $home/BirdNET-Pi/scripts/install_language_label_nm.sh && $home/BirdNET-Pi/scripts/install_language_label_nm.sh -l $language", $user);
|
||||
} else {
|
||||
syslog_shell_exec("$home/BirdNET-Pi/scripts/install_language_label.sh -l $language", $user);
|
||||
syslog(LOG_INFO, "Successfully changed language to '$language' and model to '$model'");
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Successfully changed language to '$language'");
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +277,7 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") {
|
||||
$body = str_replace("\$overlap", $overlap, $body);
|
||||
$body = str_replace("\$flickrimage", $exampleimage, $body);
|
||||
|
||||
echo "<pre class=\"bash\">".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv --plugin-path ".$home."/.apprise/plugins "." -t '".$title."' -b '".$body."' ".$attach." ".$cf." ")."</pre>";
|
||||
echo "<pre class=\"bash\">".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv --plugin-path ".$home."/.apprise/plugins "." -t '".escapeshellcmd($title)."' -b '".escapeshellcmd($body)."' ".$attach." ".$cf." ")."</pre>";
|
||||
|
||||
die();
|
||||
}
|
||||
@@ -554,7 +548,7 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
|
||||
<hr>
|
||||
<label for="minimum_time_limit">Minimum time between notifications of the same species (sec):</label>
|
||||
<input type="number" id="minimum_time_limit" name="minimum_time_limit" value="<?php echo $config['APPRISE_MINIMUM_SECONDS_BETWEEN_NOTIFICATIONS_PER_SPECIES'];?>" min="0"><br>
|
||||
<label for="only_notify_species_names">ONLY notify for these species (comma separated common names):</label>
|
||||
<label for="only_notify_species_names">Exclude these species (comma separated common names):</label>
|
||||
<input type="text" id="only_notify_species_names" placeholder="Northern Cardinal,American Crow,Carolina Chickadee" name="only_notify_species_names" value="<?php echo $config['APPRISE_ONLY_NOTIFY_SPECIES_NAMES'];?>" size=96><br>
|
||||
|
||||
<br>
|
||||
@@ -651,8 +645,11 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
|
||||
<h2>Time and Date</h2>
|
||||
<span>If connected to the internet, retrieve time automatically?</span>
|
||||
<input type="checkbox" onchange='handleChange(this)' <?php echo $checkedvalue; ?> ><br>
|
||||
<input onclick="this.showPicker()" type="date" id="date" name="date" value="<?php echo date('Y-m-d') ?>" <?php echo $disabledvalue; ?>>
|
||||
<input onclick="this.showPicker()" type="time" id="time" name="time" value="<?php echo date('H:i') ?>" <?php echo $disabledvalue; ?>><br>
|
||||
<?php
|
||||
$date = new DateTime('now');
|
||||
?>
|
||||
<input onclick="this.showPicker()" type="date" id="date" name="date" value="<?php echo $date->format('Y-m-d') ?>" <?php echo $disabledvalue; ?>>
|
||||
<input onclick="this.showPicker()" type="time" id="time" name="time" value="<?php echo $date->format('H:i'); ?>" <?php echo $disabledvalue; ?>><br>
|
||||
<label for="timezone">Select a Timezone: </label>
|
||||
<select name="timezone">
|
||||
<option disabled selected>
|
||||
|
||||
+4
-2
@@ -148,14 +148,16 @@ function submitID() {
|
||||
</table>
|
||||
<?php // <br><button type="button" onclick="showDialog()">Export as CSV for eBird</button><br><br> ?>
|
||||
<?php
|
||||
$time = time();
|
||||
|
||||
if (file_exists('./Charts/'.$chart)) {
|
||||
echo "<img src=\"/Charts/$chart?nocache=time()\" >";
|
||||
echo "<img src=\"/Charts/$chart?nocache=$time\" >";
|
||||
} else {
|
||||
echo "<p>No Charts for $theDate</p>";
|
||||
}
|
||||
echo "<hr>";
|
||||
if (file_exists('./Charts/'.$chart2)) {
|
||||
echo "<img src=\"/Charts/$chart2?nocache=time()\">";
|
||||
echo "<img src=\"/Charts/$chart2?nocache=$time\">";
|
||||
} else {
|
||||
echo "<p>No Charts For $theDate</p>";
|
||||
}?>
|
||||
|
||||
+17
-12
@@ -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');
|
||||
@@ -23,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"])) {
|
||||
?>
|
||||
@@ -73,7 +82,7 @@ if(isset($_GET['fetch_chart_string']) && $_GET['fetch_chart_string'] == "true")
|
||||
|
||||
if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
|
||||
|
||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 5');
|
||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 15');
|
||||
if($statement4 == False) {
|
||||
echo "Database is busy";
|
||||
header("refresh: 0;");
|
||||
@@ -215,7 +224,11 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
||||
}
|
||||
}
|
||||
if($iterations == 0) {
|
||||
echo "<h3>No Detections For Today.</h3>";
|
||||
if($todaycount > 0) {
|
||||
echo "<h3>Your system is currently processing a backlog of audio. This can take several hours before normal functionality of your BirdNET-Pi resumes.</h3>";
|
||||
} else {
|
||||
echo "<h3>No Detections For Today.</h3>";
|
||||
}
|
||||
}
|
||||
die();
|
||||
}
|
||||
@@ -230,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";
|
||||
@@ -309,7 +314,7 @@ body::-webkit-scrollbar {
|
||||
<h1 id="modalHeading"></h1>
|
||||
<p id="modalText"></p>
|
||||
<button onclick="hideDialog()">Close</button>
|
||||
<button style="font-weight:bold;color:blue" onclick="if(confirm('Are you sure you want to blacklist this image?')) { blacklistImage(); }">Never show this image again</button>
|
||||
<button style="font-weight:bold;color:blue" onclick="if(confirm('Are you sure you want to blacklist this image?')) { blacklistImage(); }">Blacklist this image</button>
|
||||
</dialog>
|
||||
<script src="static/dialog-polyfill.js"></script>
|
||||
<script src="static/Chart.bundle.js"></script>
|
||||
@@ -460,7 +465,7 @@ window.setInterval(function(){
|
||||
document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now();
|
||||
}, <?php echo $refresh; ?>*1000);
|
||||
|
||||
<?php if(isset($config["CUSTOM_IMAGE"])){?>
|
||||
<?php if(isset($config["CUSTOM_IMAGE"]) && strlen($config["CUSTOM_IMAGE"]) > 2){?>
|
||||
// every 1 second, this loop will run and refresh the custom image
|
||||
window.setInterval(function(){
|
||||
// Find the customimage element
|
||||
|
||||
+6
-11
@@ -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("mkdir -p ".$shifted_path.$dir." && echo \"".$cmd."\" > /tmp/shift.sh && 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("/tmp/shift.sh");
|
||||
shell_exec("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");
|
||||
$cmd = "sudo rm -f " . $shifted_path.$filename;
|
||||
shell_exec($cmd);
|
||||
}
|
||||
|
||||
echo "OK";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
ini_set('user_agent', 'PHP_Flickr/1.0');
|
||||
error_reporting(0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
ini_set('session.gc_maxlifetime', 7200);
|
||||
ini_set('user_agent', 'PHP_Flickr/1.0');
|
||||
session_set_cookie_params(7200);
|
||||
session_start();
|
||||
error_reporting(E_ERROR);
|
||||
@@ -405,7 +406,7 @@ die();
|
||||
<h1 id="modalHeading"></h1>
|
||||
<p id="modalText"></p>
|
||||
<button style="font-weight:bold;color:blue" onclick="hideDialog()">Close</button>
|
||||
<button style="font-weight:bold;color:blue" onclick="if(confirm('Are you sure you want to blacklist this image?')) { blacklistImage(); }">Never show this image again</button>
|
||||
<button style="font-weight:bold;color:blue" onclick="if(confirm('Are you sure you want to blacklist this image?')) { blacklistImage(); }">Blacklist this image</button>
|
||||
</dialog>
|
||||
<script src="static/dialog-polyfill.js"></script>
|
||||
<script src="static/Chart.bundle.js"></script>
|
||||
|
||||
@@ -11,12 +11,9 @@ 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 -R a+w $HOME/BirdNET-Pi/scripts/*.php
|
||||
chmod 666 ~/BirdNET-Pi/scripts/*.txt
|
||||
chmod 666 ~/BirdNET-Pi/*.txt
|
||||
find $HOME/BirdNET-Pi -path "$HOME/BirdNET-Pi/birdnet" -prune -o -type f ! -perm /o=w -exec chmod a+w {} \;
|
||||
|
||||
# Create blank sitename as it's optional. First time install will use $HOSTNAME.
|
||||
if ! grep SITE_NAME /etc/birdnet/birdnet.conf &>/dev/null;then
|
||||
|
||||
@@ -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')
|
||||
@@ -77,8 +77,9 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu
|
||||
if not comName in flickr_images:
|
||||
try:
|
||||
# TODO: Make this work with non-english comnames. Implement the "// convert sci name to English name" logic from overview.php here
|
||||
headers = {'User-Agent': 'Python_Flickr/1.0'}
|
||||
url = 'https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key='+str(settings_dict.get('FLICKR_API_KEY'))+'&text='+str(comName)+' bird&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1'
|
||||
resp = requests.get(url=url)
|
||||
resp = requests.get(url=url, headers=headers)
|
||||
resp.encoding = "utf-8"
|
||||
data = resp.json()["photos"]["photo"][0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user