From 49a92bae6cc2c8b4912914562284176568ce0501 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Sat, 28 May 2022 12:38:26 -0400 Subject: [PATCH] Apprise - notify each new infrequent visitor --- scripts/config.php | 2 +- scripts/server.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index 428df35..d3a8b6a 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -170,7 +170,7 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken}
> -
+
>

Bird Photos from Flickr

diff --git a/scripts/server.py b/scripts/server.py index f7a8c7b..dd386b8 100755 --- a/scripts/server.py +++ b/scripts/server.py @@ -250,19 +250,19 @@ def sendAppriseNotifications(species, confidence): if str(str(str([i for i in this_run if i.startswith('APPRISE_NOTIFY_NEW_SPECIES')]).split('=')[1]).split('\\')[0]) == "1": try: con = sqlite3.connect(userDir + '/BirdNET-Pi/scripts/birds.db') - con.row_factory = lambda cursor, row: row[0] cur = con.cursor() - cur.execute("SELECT DISTINCT(Com_Name) FROM detections") + cur.execute("SELECT DISTINCT(Com_Name), count(Com_Name) FROM detections WHERE date > (SELECT DATETIME('now', '-7 day')) GROUP BY Com_Name") known_species = cur.fetchall() sciName, comName = species.split("_") + numberDetections = [d[1] for d in known_species if d[0] == comName.replace("'","")][0] - if comName not in known_species: + if numberDetections <= 5: apobj = apprise.Apprise() config = apprise.AppriseConfig() config.add(userDir + '/BirdNET-Pi/apprise.txt') apobj.add(config) apobj.notify( - body=body.replace("$sciname", species.split("_")[0]).replace("$comname", species.split("_")[1]).replace("$confidence", confidence), + body=body.replace("$sciname", species.split("_")[0]).replace("$comname", species.split("_")[1]).replace("$confidence", confidence) + " (only seen "+str(int(numberDetections)+1)+" times in last 7d)", title=title, )