cleanup usage of labels.txt a bit
This commit is contained in:
+2
-22
@@ -93,32 +93,12 @@ function debug_log($message) {
|
||||
|
||||
function get_com_en_name($sci_name) {
|
||||
if (!isset($_labels_flickr)) {
|
||||
$_labels_flickr = file(get_home() . "/BirdNET-Pi/model/labels_flickr.txt");
|
||||
}
|
||||
$engname = null;
|
||||
foreach ($_labels_flickr as $label) {
|
||||
if (trim(explode("_", $label)[0]) === $sci_name) {
|
||||
$engname = trim(explode("_", $label)[1]);
|
||||
break;
|
||||
}
|
||||
$_labels_flickr = json_decode(file_get_contents(get_home() . "/BirdNET-Pi/model/l18n/labels_en.json"), true);
|
||||
}
|
||||
$engname = $_labels_flickr[$sci_name];
|
||||
return $engname;
|
||||
}
|
||||
|
||||
function get_sci_name($com_name) {
|
||||
if (!isset($_labels)) {
|
||||
$_labels = file(get_home() . "/BirdNET-Pi/model/labels.txt");
|
||||
}
|
||||
$sciname = null;
|
||||
foreach ($_labels as $label) {
|
||||
if (trim(explode("_", $label)[1]) === $com_name) {
|
||||
$sciname = trim(explode("_", $label)[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $sciname;
|
||||
}
|
||||
|
||||
function get_label($record, $sort_by, $date=null) {
|
||||
$name = $record["Com_Name"];
|
||||
if ($sort_by == "confidence") {
|
||||
|
||||
+3
-2
@@ -639,8 +639,9 @@ echo "<table>
|
||||
$statement2 = $db->prepare("SELECT * FROM detections where File_name == \"$name\" ORDER BY Date DESC, Time DESC");
|
||||
ensure_db_ok($statement2);
|
||||
$result2 = $statement2->execute();
|
||||
$comname = str_replace("_", " ", strtok($name, '-'));
|
||||
$sciname = get_sci_name($comname);
|
||||
$results = $result2->fetchArray(SQLITE3_ASSOC);
|
||||
$sciname = $results['Sci_Name'];
|
||||
$result2->reset();
|
||||
$info_url = get_info_url($sciname);
|
||||
$url = $info_url['URL'];
|
||||
echo "<table>
|
||||
|
||||
@@ -253,10 +253,10 @@ AUTH=$(grep basicauth /etc/caddy/Caddyfile)
|
||||
[ -n "${CADDY_PWD}" ] && [ -z "${AUTH}" ] && sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1
|
||||
set -x
|
||||
|
||||
if ! [ -L $HOME/BirdNET-Pi/model/labels_flickr.txt ]; then
|
||||
sudo_with_user ln -sf labels_nm/labels_en.txt $HOME/BirdNET-Pi/model/labels_flickr.txt
|
||||
if [ -L $HOME/BirdNET-Pi/model/labels_flickr.txt ]; then
|
||||
rm $HOME/BirdNET-Pi/model/labels_flickr.txt
|
||||
fi
|
||||
if ! [ -L $HOME/BirdNET-Pi/model/labels.txt ]; then
|
||||
if [ -L $HOME/BirdNET-Pi/model/labels.txt ]; then
|
||||
sudo_with_user install_language_label.sh
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user