diff --git a/.gitignore b/.gitignore index c622287..99afbb4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,14 @@ birdnet.conf IdentifiedSoFar.txt IdentifiedSoFar.txt.bak Birders_Guide_Installer_Configuration.txt +birdnet/ +templates/*.service +scripts/*.txt +scripts/birds.db +analyzing_now.txt +apprise.txt +BirdDB.txt +exclude_species_list.txt +firstrun.ini +HUMAN.txt +include_species_list.txt diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/homepage/views.php b/homepage/views.php index 3fc111c..dd75f00 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -116,7 +116,7 @@ if(isset($_GET['view'])){ - + diff --git a/requirements.txt b/requirements.txt index c407877..9838280 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,5 @@ streamlit plotly apprise paho-mqtt +pytest==7.1.2 +pytest-mock==3.7.0 diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/config.php b/scripts/config.php index 9923158..023499e 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -41,6 +41,11 @@ if(isset($_GET["latitude"])){ } else { $apprise_notify_new_species = 0; } + if(isset($_GET['apprise_notify_new_species_each_day'])) { + $apprise_notify_new_species_each_day = 1; + } else { + $apprise_notify_new_species_each_day = 0; + } if(isset($timezone)) { shell_exec("sudo timedatectl set-timezone ".$timezone); @@ -92,9 +97,10 @@ if(isset($_GET["latitude"])){ $contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents); $contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents); $contents = preg_replace("/APPRISE_NOTIFICATION_TITLE=.*/", "APPRISE_NOTIFICATION_TITLE=\"$apprise_notification_title\"", $contents); - $contents = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY=\"$apprise_notification_body\"", $contents); + $contents = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY='$apprise_notification_body'", $contents); $contents = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents); $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents); + $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents); $contents = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents); $contents = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents); $contents = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents); @@ -104,9 +110,10 @@ if(isset($_GET["latitude"])){ $contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2); $contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFICATION_TITLE=.*/", "APPRISE_NOTIFICATION_TITLE=\"$apprise_notification_title\"", $contents2); - $contents2 = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY=\"$apprise_notification_body\"", $contents2); + $contents2 = preg_replace("/APPRISE_NOTIFICATION_BODY=.*/", "APPRISE_NOTIFICATION_BODY='$apprise_notification_body'", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents2); + $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents2); $contents2 = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents2); $contents2 = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents2); $contents2 = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents2); @@ -150,10 +157,18 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $result0 = $statement0->execute(); while($todaytable=$result0->fetchArray(SQLITE3_ASSOC)) { - $comname = $todaytable['Com_Name']; - $filename = $todaytable['File_Name']; $sciname = $todaytable['Sci_Name']; - $confidence = $todaytable["Confidence"]; + $comname = $todaytable['Com_Name']; + $confidence = $todaytable['Confidence']; + $filename = $todaytable['File_Name']; + $date = $todaytable['Date']; + $time = $todaytable['Time']; + $week = $todaytable['Week']; + $latitude = $todaytable['Lat']; + $longitude = $todaytable['Lon']; + $cutoff = $todaytable['Cutoff']; + $sens = $todaytable['Sens']; + $overlap = $todaytable['Overlap']; } $title = $_GET['apprise_notification_title']; @@ -165,15 +180,31 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $filename = "http://birdnetpi.local/"."?filename=".$filename; } - $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$sciname", $sciname, $title); + $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$confidence", $confidence, $title); $title = str_replace("\$listenurl", $filename, $title); + $title = str_replace("\$date", $date, $title); + $title = str_replace("\$time", $time, $title); + $title = str_replace("\$week", $week, $title); + $title = str_replace("\$latitude", $latitude, $title); + $title = str_replace("\$longitude", $longitude, $title); + $title = str_replace("\$cutoff", $cutoff, $title); + $title = str_replace("\$sens", $sens, $title); + $title = str_replace("\$overlap", $overlap, $title); - $body = str_replace("\$comname", $comname, $body); $body = str_replace("\$sciname", $sciname, $body); + $body = str_replace("\$comname", $comname, $body); $body = str_replace("\$confidence", $confidence, $body); $body = str_replace("\$listenurl", $filename, $body); + $body = str_replace("\$date", $date, $body); + $body = str_replace("\$time", $time, $body); + $body = str_replace("\$week", $week, $body); + $body = str_replace("\$latitude", $latitude, $body); + $body = str_replace("\$longitude", $longitude, $body); + $body = str_replace("\$cutoff", $cutoff, $body); + $body = str_replace("\$sens", $sens, $body); + $body = str_replace("\$overlap", $overlap, $body); echo "
".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv -t '".$title."' -b '".$body."' ".$cf." ").""; @@ -273,14 +304,32 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
Use the variables defined above to customize your notification title and body.