diff --git a/homepage/views.php b/homepage/views.php index 8a5cbe1..b2f2205 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -142,6 +142,7 @@ if(isset($_GET['view'])){ + "; } @@ -204,6 +205,33 @@ if(isset($_GET['view'])){ } include('./scripts/exclude_list.php'); } + if($_GET['view'] == "Whitelisted"){ + ensure_authenticated(); + if(isset($_GET['species']) && isset($_GET['add'])){ + $file = './scripts/whitelist_species_list.txt'; + $str = file_get_contents("$file"); + $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str); + file_put_contents("$file", "$str"); + foreach ($_GET['species'] as $selectedOption) + file_put_contents("./scripts/whitelist_species_list.txt", htmlspecialchars_decode($selectedOption, ENT_QUOTES)."\n", FILE_APPEND); + } elseif (isset($_GET['species']) && isset($_GET['del'])){ + $file = './scripts/whitelist_species_list.txt'; + $str = file_get_contents("$file"); + $str = preg_replace('/^\h*\v+/m', '', $str); + file_put_contents("$file", "$str"); + foreach($_GET['species'] as $selectedOption) { + $content = file_get_contents("./scripts/whitelist_species_list.txt"); + $newcontent = str_replace($selectedOption, "", "$content"); + $newcontent = str_replace(htmlspecialchars_decode($selectedOption, ENT_QUOTES), "", "$content"); + file_put_contents("./scripts/whitelist_species_list.txt", "$newcontent"); + } + $file = './scripts/whitelist_species_list.txt'; + $str = file_get_contents("$file"); + $str = preg_replace('/^\h*\v+/m', '', $str); + file_put_contents("$file", "$str"); + } + include('./scripts/whitelist_list.php'); + } if($_GET['view'] == "File"){ echo ""; } diff --git a/scripts/clear_all_data.sh b/scripts/clear_all_data.sh index 9330ef1..ee9d88d 100755 --- a/scripts/clear_all_data.sh +++ b/scripts/clear_all_data.sh @@ -24,6 +24,7 @@ echo "Re-creating necessary directories" sudo -u ${USER} ln -fs $(dirname $my_dir)/exclude_species_list.txt $my_dir sudo -u ${USER} ln -fs $(dirname $my_dir)/include_species_list.txt $my_dir +sudo -u ${USER} ln -fs $(dirname $my_dir)/whitelist_species_list.txt $my_dir sudo -u ${USER} ln -fs $(dirname $my_dir)/homepage/* ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname $my_dir)/model/labels.txt ${my_dir} sudo -u ${USER} ln -fs $my_dir ${EXTRACTED} diff --git a/scripts/install_services.sh b/scripts/install_services.sh index e944b5a..0ef70bb 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -66,6 +66,7 @@ create_necessary_dirs() { sudo -u ${USER} ln -fs $my_dir/exclude_species_list.txt $my_dir/scripts sudo -u ${USER} ln -fs $my_dir/include_species_list.txt $my_dir/scripts + sudo -u ${USER} ln -fs $my_dir/whitelist_species_list.txt $my_dir/scripts sudo -u ${USER} ln -fs $my_dir/homepage/* ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/model/labels.txt ${my_dir}/scripts sudo -u ${USER} ln -fs $my_dir/scripts ${EXTRACTED} diff --git a/scripts/server.py b/scripts/server.py index ea4e563..c7803e0 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -135,6 +135,9 @@ def predictSpeciesList(lat, lon, week): # if there's a custom user-made include list, we only want to use the species in that if (len(INCLUDE_LIST) == 0): PREDICTED_SPECIES_LIST.append(s[1]) + WHITELIST_LIST = loadCustomSpeciesList(os.path.expanduser("~/BirdNET-Pi/whitelist_species_list.txt")) + for species in WHITELIST_LIST: + PREDICTED_SPECIES_LIST.append(species) def loadCustomSpeciesList(path): diff --git a/scripts/whitelist_list.php b/scripts/whitelist_list.php new file mode 100644 index 0000000..a7a0b11 --- /dev/null +++ b/scripts/whitelist_list.php @@ -0,0 +1,105 @@ + + + +
+
+

All Species Labels

+ +
+ Once the desired species has been highlighted, click it and then click ADD to have it whitelisted. This species will be detected even if below the Species Occurence Frequency Threshold defined in the settings. + This is not a recommended way of working : it is preferable to first try first both Species Occurence models (v1 and v2.4). + + +
+
+ +
+
+ +
+
+ +

+ +
+
+ +
+
+

Whitelisted Species List

+


+ + +
+
+ +
+
+ +