mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-23 07:46:05 +02:00
Confirmed working
This commit is contained in:
@@ -62,11 +62,8 @@ def get_bird_code(scientific_name):
|
|||||||
array_str = re.search(r'\$ebirds = \[(.*?)\];', data, re.DOTALL).group(1)
|
array_str = re.search(r'\$ebirds = \[(.*?)\];', data, re.DOTALL).group(1)
|
||||||
|
|
||||||
# Convert the PHP array to a Python dictionary
|
# Convert the PHP array to a Python dictionary
|
||||||
bird_dict = {}
|
bird_dict = {re.search(r'"(.*?)"', line).group(1): re.search(r'=> "(.*?)"', line).group(1)
|
||||||
for line in array_str.split('\n'):
|
for line in array_str.split('\n') if '=>' in line}
|
||||||
if '=>' in line:
|
|
||||||
key, value = map(lambda x: x.strip(' "'), line.split('=>'))
|
|
||||||
bird_dict[key] = value
|
|
||||||
|
|
||||||
# Return the corresponding value for the given bird's scientific name
|
# Return the corresponding value for the given bird's scientific name
|
||||||
return bird_dict.get(scientific_name)
|
return bird_dict.get(scientific_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user