mirror of https://gitlab.com/bashrc2/epicyon
Check property types
parent
464746fe9c
commit
f84bda8f4a
28
website.py
28
website.py
|
|
@ -31,6 +31,8 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
||||||
"""
|
"""
|
||||||
if not actor_json.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
|
if not isinstance(actor_json['attachment'], list):
|
||||||
|
return ''
|
||||||
website_str = translate['Website'].lower()
|
website_str = translate['Website'].lower()
|
||||||
match_strings = _get_website_strings()
|
match_strings = _get_website_strings()
|
||||||
match_strings.append(website_str)
|
match_strings.append(website_str)
|
||||||
|
|
@ -38,15 +40,17 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
||||||
if not isinstance(property_value, dict):
|
if not isinstance(property_value, dict):
|
||||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||||
continue
|
continue
|
||||||
name_value = None
|
name_value: str = None
|
||||||
if property_value.get('name'):
|
if property_value.get('name'):
|
||||||
name_value = property_value['name']
|
if isinstance(property_value['name'], str):
|
||||||
|
name_value = property_value['name']
|
||||||
elif property_value.get('schema:name'):
|
elif property_value.get('schema:name'):
|
||||||
name_value = property_value['schema:name']
|
if isinstance(property_value['schema:name'], str):
|
||||||
|
name_value = property_value['schema:name']
|
||||||
if not name_value:
|
if not name_value:
|
||||||
continue
|
continue
|
||||||
found: bool = False
|
found: bool = False
|
||||||
name_value_lower = name_value.lower()
|
name_value_lower: str = name_value.lower()
|
||||||
if name_value_lower.endswith(' ' + website_str) or \
|
if name_value_lower.endswith(' ' + website_str) or \
|
||||||
name_value_lower.endswith(' homepage'):
|
name_value_lower.endswith(' homepage'):
|
||||||
found = True
|
found = True
|
||||||
|
|
@ -65,7 +69,7 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value['type'].endswith('PropertyValue'):
|
if not property_value['type'].endswith('PropertyValue'):
|
||||||
continue
|
continue
|
||||||
value_str = remove_html(property_value[prop_value_name])
|
value_str: str = remove_html(property_value[prop_value_name])
|
||||||
if 'https://' not in value_str and \
|
if 'https://' not in value_str and \
|
||||||
'http://' not in value_str:
|
'http://' not in value_str:
|
||||||
continue
|
continue
|
||||||
|
|
@ -78,16 +82,20 @@ def get_gemini_link(actor_json: {}) -> str:
|
||||||
"""
|
"""
|
||||||
if not actor_json.get('attachment'):
|
if not actor_json.get('attachment'):
|
||||||
return ''
|
return ''
|
||||||
|
if not isinstance(actor_json['attachment'], list):
|
||||||
|
return ''
|
||||||
match_strings = _get_gemini_strings()
|
match_strings = _get_gemini_strings()
|
||||||
for property_value in actor_json['attachment']:
|
for property_value in actor_json['attachment']:
|
||||||
if not isinstance(property_value, dict):
|
if not isinstance(property_value, dict):
|
||||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||||
continue
|
continue
|
||||||
name_value = None
|
name_value: str = None
|
||||||
if property_value.get('name'):
|
if property_value.get('name'):
|
||||||
name_value = property_value['name']
|
if isinstance(property_value['name'], str):
|
||||||
|
name_value = property_value['name']
|
||||||
elif property_value.get('schema:name'):
|
elif property_value.get('schema:name'):
|
||||||
name_value = property_value['schema:name']
|
if isinstance(property_value['schema:name'], str):
|
||||||
|
name_value = property_value['schema:name']
|
||||||
if not name_value:
|
if not name_value:
|
||||||
continue
|
continue
|
||||||
if name_value.lower() not in match_strings:
|
if name_value.lower() not in match_strings:
|
||||||
|
|
@ -100,7 +108,7 @@ def get_gemini_link(actor_json: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value['type'].endswith('PropertyValue'):
|
if not property_value['type'].endswith('PropertyValue'):
|
||||||
continue
|
continue
|
||||||
url = remove_html(property_value[prop_value_name])
|
url: str = remove_html(property_value[prop_value_name])
|
||||||
return remove_link_tracking(url)
|
return remove_link_tracking(url)
|
||||||
|
|
||||||
for property_value in actor_json['attachment']:
|
for property_value in actor_json['attachment']:
|
||||||
|
|
@ -115,7 +123,7 @@ def get_gemini_link(actor_json: {}) -> str:
|
||||||
continue
|
continue
|
||||||
if not property_value['type'].endswith('PropertyValue'):
|
if not property_value['type'].endswith('PropertyValue'):
|
||||||
continue
|
continue
|
||||||
url = remove_html(property_value[prop_value_name])
|
url: str = remove_html(property_value[prop_value_name])
|
||||||
if 'gemini://' not in url:
|
if 'gemini://' not in url:
|
||||||
continue
|
continue
|
||||||
return remove_link_tracking(url)
|
return remove_link_tracking(url)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue