diff --git a/scripts/config.php b/scripts/config.php index 2aafa7f..a4631c0 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -187,6 +187,11 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $filename = "http://birdnetpi.local/"."?filename=".$filename; } + $attach=""; + if (strpos($body, '$flickrimage') !== false) { + $attach = "--attach https://live.staticflickr.com/7430/27545810581_8bfa8289a3_c.jpg"; + } + $title = str_replace("\$sciname", $sciname, $title); $title = str_replace("\$comname", $comname, $title); $title = str_replace("\$confidence", $confidence, $title); @@ -199,6 +204,7 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $title = str_replace("\$cutoff", $cutoff, $title); $title = str_replace("\$sens", $sens, $title); $title = str_replace("\$overlap", $overlap, $title); + $title = str_replace("\$flickrimage", "", $title); $body = str_replace("\$sciname", $sciname, $body); $body = str_replace("\$comname", $comname, $body); @@ -212,8 +218,9 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") { $body = str_replace("\$cutoff", $cutoff, $body); $body = str_replace("\$sens", $sens, $body); $body = str_replace("\$overlap", $overlap, $body); + $body = str_replace("\$flickrimage", "", $body); - echo "
".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv -t '".$title."' -b '".$body."' ".$cf." ")."
"; + echo "
".shell_exec($home."/BirdNET-Pi/birdnet/bin/apprise -vv -t '".$title."' -b '".$body."' ".$attach." ".$cf." ")."
"; die(); } @@ -327,6 +334,8 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
Sigmoid Sensitivity set in "Advanced Settings"
$overlap
Overlap set in "Advanced Settings"
+
$flickrimage
+
A preview image of the detected species from Flickr. Set your API key below.

Use the variables defined above to customize your notification title and body.

diff --git a/scripts/history.php b/scripts/history.php index 88ca352..09afbd9 100644 --- a/scripts/history.php +++ b/scripts/history.php @@ -1,7 +1,6 @@ if($config["FULL_DISK"] == "purge") { if(!in_array($filename_formatted, $disk_check_exclude_arr)) { $imageicon = "images/unlock.svg"; - $title = "This file is not delete protected."; + $title = "This file is not excluded from being purged."; $type = "add"; } else { $imageicon = "images/lock.svg"; - $title = "This file is delete protected."; + $title = "This file is excluded from being purged."; $type = "del"; } @@ -379,11 +380,11 @@ echo " if($config["FULL_DISK"] == "purge") { if(!in_array($filename_formatted, $disk_check_exclude_arr)) { $imageicon = "images/unlock.svg"; - $title = "This file is not delete protected."; + $title = "This file is not excluded from being purged."; $type = "add"; } else { $imageicon = "images/lock.svg"; - $title = "This file is delete protected."; + $title = "This file is excluded from being purged."; $type = "del"; } diff --git a/scripts/spectrogram.php b/scripts/spectrogram.php index a128d21..cf1f687 100644 --- a/scripts/spectrogram.php +++ b/scripts/spectrogram.php @@ -1,4 +1,6 @@ 0 and "$flickrimage" in body: + if not comName in flickr_images: + try: + # TODO: Make this work with non-english comnames. Implement the "// convert sci name to English name" logic from overview.php here + url = 'https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key='+str(settings_dict.get('FLICKR_API_KEY'))+'&text='+str(comName)+'&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1' + resp = requests.get(url=url) + data = resp.json()["photos"]["photo"][0] + + image_url = 'https://farm'+str(data["farm"])+'.static.flickr.com/'+str(data["server"])+'/'+str(data["id"])+'_'+str(data["secret"])+'_n.jpg' + flickr_images[comName] = image_url + except ValueError: + image_url = None + else: + image_url = flickr_images[comName] + if settings_dict.get('APPRISE_NOTIFY_EACH_DETECTION') == "1": notify_body = body.replace("$sciname", sciName)\ @@ -50,6 +76,7 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap) notify_title = title.replace("$sciname", sciName)\ .replace("$comname", comName)\ @@ -62,8 +89,9 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap) - notify(notify_body, notify_title) + notify(notify_body, notify_title, image_url) APPRISE_NOTIFICATION_NEW_SPECIES_DAILY_COUNT_LIMIT = 1 # Notifies the first N per day. if settings_dict.get('APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY') == "1": @@ -90,6 +118,7 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap)\ + " (first time today)" notify_title = title.replace("$sciname", sciName)\ @@ -103,9 +132,10 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap)\ + " (first time today)" - notify(notify_body, notify_title) + notify(notify_body, notify_title, image_url) con.close() except sqlite3.Error as e: print(e) @@ -135,6 +165,7 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap)\ + " (only seen " + str(int(numberDetections)) + " times in last 7d)" notify_title = title.replace("$sciname", sciName)\ @@ -148,9 +179,10 @@ def sendAppriseNotifications(species, confidence, path, date, time, week, latitu .replace("$longitude", longitude)\ .replace("$cutoff", cutoff)\ .replace("$sens", sens)\ + .replace("$flickrimage", "")\ .replace("$overlap", overlap)\ + " (only seen " + str(int(numberDetections)) + " times in last 7d)" - notify(notify_body, notify_title) + notify(notify_body, notify_title, image_url) con.close() except sqlite3.Error: print("Database busy")