Skip to content

A live bird collage card for your Home Assistant dashboard.

allaboutbirds/ebird url generation

frederikbe8093d663b6
diff --git a/scripts/common.php b/scripts/common.php
index 50c52d48..2e654c92 100644
--- a/scripts/common.php
+++ b/scripts/common.php
@@ -260,3 +260,25 @@ class Flickr {
}
}
+
+function get_info_url($sciname){
+ $engname = get_com_en_name($sciname);
+ $config = get_config();
+ if ($config['INFO_SITE'] === 'EBIRD'){
+ require 'scripts/ebird.php';
+ $ebird = $ebirds[$sciname];
+ debug_log($ebird);
+ $language = $config['DATABASE_LANG'];
+ $url = "https://ebird.org/species/$ebird?siteLanguage=$language";
+ $url_title = "eBirds";
+ } else {
+ $engname_url = str_replace("'", '', str_replace(' ', '_', $engname));
+ $url = "https://allaboutbirds.org/guide/$engname_url";
+ $url_title = "All About Birds";
+ }
+ $ret = array(
+ 'URL' => $url,
+ 'TITLE' => $url_title
+ );
+ return $ret;
+}
diff --git a/scripts/stats.php b/scripts/stats.php
index 78f0988a..8cb4ba03 100644
--- a/scripts/stats.php
+++ b/scripts/stats.php
@@ -164,15 +164,18 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){
$comname = preg_replace('/\'/', '', $comname);
$linkname = preg_replace('/_/', '+', $dbsciname);
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
- $engname = get_com_en_name($results['Sci_Name']);
- $engname_url = str_replace("'", '', str_replace(' ', '_', $engname));
+ $engname = get_com_en_name($sciname);
+
+ $info_url = get_info_url($results['Sci_Name']);
+ $url = $info_url['URL'];
+ $url_title = $info_url['TITLE'];
echo str_pad("<h3>$species</h3>
<table><tr>
<td class=\"relative\"><a target=\"_blank\" href=\"index.php?filename=".$results['File_Name']."\"><img title=\"Open in new tab\" class=\"copyimage\" width=25 src=\"images/copy.png\"></a> <a href=\"https://wikipedia.org/wiki/$dbsciname\" target=\"top\"/><i>$sciname</i></a><br>
<b>Occurrences: </b>$count<br>
<b>Max Confidence: </b>$maxconf<br>
<b>Best Recording: </b>$date $time<br>
- <a href=\"https://allaboutbirds.org/guide/$engname_url\" target=\"top\"/>All About Birds</a><br>
+ <a href=\"$url\" target=\"top\"/>$url_title</a><br>
<video onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster=\"$filename.png\" title=\"$filename\"><source src=\"$filename\"></video></td>
</tr>
</table>
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index c819e4ba..5a1f0889 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -198,6 +198,10 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
$engname = get_com_en_name($todaytable['Sci_Name']);
$engname_url = str_replace("'", '', str_replace(' ', '_', $engname));
+ $info_url = get_info_url($todaytable['Sci_Name']);
+ $url = $info_url['URL'];
+ $url_title = $info_url['TITLE'];
+
if (!empty($config["FLICKR_API_KEY"]) && (isset($_GET['display_limit']) || isset($_GET['hard_limit']) || $_GET['kiosk'] == true) ) {
if ($flickr === null) {
$flickr = new Flickr();
@@ -232,7 +236,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
<?php } ?>
<?php echo $todaytable['Time'];?><br>
- <b><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $engname_url;?>" target="top"><?php echo $todaytable['Com_Name'];?></a></b><img style="height: 1em;cursor:pointer" title="View species stats" onclick="generateMiniGraph(this, '<?php echo $comname; ?>')" width=25 src="images/chart.svg"><br>
+ <b><a class="a2" href="<?php echo $url;?>" target="top"><?php echo $todaytable['Com_Name'];?></a></b><img style="height: 1em;cursor:pointer" title="<?php echo $url_title;?>" onclick="generateMiniGraph(this, '<?php echo $comname; ?>')" width=25 src="images/chart.svg"><br>
<a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top"><i><?php echo $todaytable['Sci_Name'];?></i></a><br>
<b>Confidence:</b> <?php echo round((float)round($todaytable['Confidence'],2) * 100 ) . '%';?><br></div><br>
<video onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source preload="none" src="<?php echo $filename;?>"></video>
@@ -248,7 +252,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
<?php } ?>
</div>
<div>
- <b><a class="a2" <?php if($_GET['kiosk'] == false){?>href="https://allaboutbirds.org/guide/<?php echo $engname_url;?>"<?php } else {echo "style='color:blue;'";} ?> target="top"><?php echo $todaytable['Com_Name'];?></a></b>
+ <b><a class="a2" <?php if($_GET['kiosk'] == false){?>href="<?php echo $url;?>"<?php } else {echo "style='color:blue;'";} ?> target="top"><?php echo $todaytable['Com_Name'];?></a></b>
<?php
//If on mobile, add in a icon to link off to the recording so the user can see more info
if (isset($_GET['mobile'])) {