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) {
|
function get_com_en_name($sci_name) {
|
||||||
if (!isset($_labels_flickr)) {
|
if (!isset($_labels_flickr)) {
|
||||||
$_labels_flickr = file(get_home() . "/BirdNET-Pi/model/labels_flickr.txt");
|
$_labels_flickr = json_decode(file_get_contents(get_home() . "/BirdNET-Pi/model/l18n/labels_en.json"), true);
|
||||||
}
|
|
||||||
$engname = null;
|
|
||||||
foreach ($_labels_flickr as $label) {
|
|
||||||
if (trim(explode("_", $label)[0]) === $sci_name) {
|
|
||||||
$engname = trim(explode("_", $label)[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$engname = $_labels_flickr[$sci_name];
|
||||||
return $engname;
|
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) {
|
function get_label($record, $sort_by, $date=null) {
|
||||||
$name = $record["Com_Name"];
|
$name = $record["Com_Name"];
|
||||||
if ($sort_by == "confidence") {
|
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");
|
$statement2 = $db->prepare("SELECT * FROM detections where File_name == \"$name\" ORDER BY Date DESC, Time DESC");
|
||||||
ensure_db_ok($statement2);
|
ensure_db_ok($statement2);
|
||||||
$result2 = $statement2->execute();
|
$result2 = $statement2->execute();
|
||||||
$comname = str_replace("_", " ", strtok($name, '-'));
|
$results = $result2->fetchArray(SQLITE3_ASSOC);
|
||||||
$sciname = get_sci_name($comname);
|
$sciname = $results['Sci_Name'];
|
||||||
|
$result2->reset();
|
||||||
$info_url = get_info_url($sciname);
|
$info_url = get_info_url($sciname);
|
||||||
$url = $info_url['URL'];
|
$url = $info_url['URL'];
|
||||||
echo "<table>
|
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
|
[ -n "${CADDY_PWD}" ] && [ -z "${AUTH}" ] && sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if ! [ -L $HOME/BirdNET-Pi/model/labels_flickr.txt ]; then
|
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
|
rm $HOME/BirdNET-Pi/model/labels_flickr.txt
|
||||||
fi
|
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
|
sudo_with_user install_language_label.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user