satisfy flake8 linter
This commit is contained in:
@@ -24,6 +24,7 @@ config = apprise.AppriseConfig()
|
||||
config.add(APPRISE_CONFIG)
|
||||
apobj.add(config)
|
||||
|
||||
|
||||
def notify(body, title, attached=""):
|
||||
if attached != "":
|
||||
apobj.notify(
|
||||
@@ -38,7 +39,9 @@ def notify(body, title, attached=""):
|
||||
)
|
||||
|
||||
|
||||
def sendAppriseNotifications(species, confidence, confidencepct, path, date, time, week, latitude, longitude, cutoff, sens, overlap, settings_dict, db_path=DB_PATH):
|
||||
def sendAppriseNotifications(species, confidence, confidencepct, path,
|
||||
date, time, week, latitude, longitude, cutoff,
|
||||
sens, overlap, settings_dict, db_path=DB_PATH):
|
||||
# print(sendAppriseNotifications)
|
||||
# print(settings_dict)
|
||||
if os.path.exists(APPRISE_CONFIG) and os.path.getsize(APPRISE_CONFIG) > 0:
|
||||
@@ -57,7 +60,7 @@ def sendAppriseNotifications(species, confidence, confidencepct, path, date, tim
|
||||
print("APPRISE NOTIFICATION EXCEPTION: "+str(e))
|
||||
return
|
||||
|
||||
#TODO: this all needs to be changed, we changed the caddy default to allow direct IP access, so birdnetpi.local shouldn't be relied on anymore
|
||||
# TODO: this all needs to be changed, we changed the caddy default to allow direct IP access, so birdnetpi.local shouldn't be relied on anymore
|
||||
try:
|
||||
websiteurl = settings_dict.get('BIRDNETPI_URL')
|
||||
if len(websiteurl) == 0:
|
||||
@@ -69,10 +72,11 @@ def sendAppriseNotifications(species, confidence, confidencepct, path, date, tim
|
||||
image_url = ""
|
||||
|
||||
if len(settings_dict.get('FLICKR_API_KEY')) > 0 and "$flickrimage" in body:
|
||||
if not comName in flickr_images:
|
||||
if comName not 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)+' bird&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1'
|
||||
url = 'https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key='+str(settings_dict.get('FLICKR_API_KEY'))+'&text='+str(
|
||||
comName)+' bird&sort=relevance&per_page=5&media=photos&format=json&license=2%2C3%2C4%2C5%2C6%2C9&nojsoncallback=1'
|
||||
resp = requests.get(url=url)
|
||||
resp.encoding = "utf-8"
|
||||
data = resp.json()["photos"]["photo"][0]
|
||||
@@ -80,12 +84,11 @@ def sendAppriseNotifications(species, confidence, confidencepct, path, date, tim
|
||||
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 Exception as e:
|
||||
print("FLICKR API ERROR: "+str(e))
|
||||
print("FLICKR API ERROR: "+str(e))
|
||||
image_url = ""
|
||||
else:
|
||||
image_url = flickr_images[comName]
|
||||
|
||||
|
||||
if settings_dict.get('APPRISE_NOTIFY_EACH_DETECTION') == "1":
|
||||
notify_body = body.replace("$sciname", sciName)\
|
||||
.replace("$comname", comName)\
|
||||
|
||||
Reference in New Issue
Block a user