mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-18 06:41:51 +02:00
Update birdnet_to_mqtt.py
This commit is contained in:
@@ -64,7 +64,7 @@ def automatic_mqtt_publish(file, detections, path):
|
|||||||
|
|
||||||
# Flickimage
|
# Flickimage
|
||||||
image_url = ""
|
image_url = ""
|
||||||
common_name = high_bird_fields[3]
|
common_name = detection.common_name
|
||||||
if len(settings_dict.get('FLICKR_API_KEY')) > 0:
|
if len(settings_dict.get('FLICKR_API_KEY')) > 0:
|
||||||
if common_name not in flickr_images:
|
if common_name not in flickr_images:
|
||||||
try:
|
try:
|
||||||
@@ -77,12 +77,12 @@ def automatic_mqtt_publish(file, detections, path):
|
|||||||
data = resp.json()["photos"]["photo"][0]
|
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'
|
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
|
flickr_images[common_name] = image_url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("FLICKR API ERROR: "+str(e))
|
print("FLICKR API ERROR: "+str(e))
|
||||||
image_url = ""
|
image_url = ""
|
||||||
else:
|
else:
|
||||||
image_url = flickr_images[comName]
|
image_url = flickr_images[common_name]
|
||||||
bird['Flickrimage'] = image_url
|
bird['Flickrimage'] = image_url
|
||||||
|
|
||||||
json_bird = json.dumps(bird)
|
json_bird = json.dumps(bird)
|
||||||
|
|||||||
Reference in New Issue
Block a user