From ed68f0661734c60379c590a9b6d47a6927e56ab9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 23 Jun 2024 09:52:20 +0200 Subject: [PATCH] Feat : Add site_info to the title of the species accessed through Recordings or Unique species (#113) * Add description to title * Update play.php * Add get_sci_name function * Implement get_sci_name * Removed as less relevant * Add info_site also when opening from filenames * Correct * Restore initial name * Need to use labels.txt for right language * Use $_labels in get_sci_name --- scripts/common.php | 14 ++++++++++++++ scripts/play.php | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/common.php b/scripts/common.php index 80d97ec..c9ab36a 100644 --- a/scripts/common.php +++ b/scripts/common.php @@ -103,6 +103,20 @@ function get_com_en_name($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 (strpos($label, $com_name) !== false) { + $sciname = trim(explode("_", $label)[0]); + break; + } + } + return $sciname; +} + define('DB', './scripts/flickr.db'); class Flickr { diff --git a/scripts/play.php b/scripts/play.php index dc9286f..8583de6 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -558,9 +558,12 @@ while ($result2->fetchArray(SQLITE3_ASSOC)) { $num_rows++; } $result2->reset(); // reset the pointer to the beginning of the result set +$sciname = get_sci_name($name); +$info_url = get_info_url($sciname); +$url = $info_url['URL']; echo " - + "; $iter=0; while($results=$result2->fetchArray(SQLITE3_ASSOC)) @@ -641,9 +644,13 @@ echo "
$name$name
$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); + $info_url = get_info_url($sciname); + $url = $info_url['URL']; echo "
- + "; while($results=$result2->fetchArray(SQLITE3_ASSOC)) {
$name$name