More robust detection of website property

main
Bob Mottram 2025-05-16 15:08:17 +01:00
parent d985415ce9
commit c13c0b0943
1 changed files with 11 additions and 5 deletions

View File

@ -26,8 +26,9 @@ def get_website(actor_json: {}, translate: {}) -> str:
""" """
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
website_str = translate['Website'].lower()
match_strings = _get_website_strings() match_strings = _get_website_strings()
match_strings.append(translate['Website'].lower()) match_strings.append(website_str)
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
@ -37,10 +38,15 @@ def get_website(actor_json: {}, translate: {}) -> str:
if not name_value: if not name_value:
continue continue
found = False found = False
for possible_str in match_strings: name_value_lower = name_value.lower()
if possible_str in name_value.lower(): if name_value_lower.endswith(' ' + website_str) or \
found = True name_value_lower.endswith(' homepage'):
break found = True
else:
for possible_str in match_strings:
if possible_str in name_value_lower:
found = True
break
if not found: if not found:
continue continue
if not property_value.get('type'): if not property_value.get('type'):