diff options
author | Michael Manfre | 2022-12-17 17:42:29 -0500 |
---|---|---|
committer | GitHub | 2022-12-17 15:42:29 -0700 |
commit | ea99f65c26e476b3b10c9ae5047e0f2941e9c019 (patch) | |
tree | 2f2938070692ac6530c11ef585b76da8c3c417ff /core | |
parent | 24b5d08f9b7e987a578143aea98ccaa69ba80ce5 (diff) | |
download | takahe-ea99f65c26e476b3b10c9ae5047e0f2941e9c019.tar.gz takahe-ea99f65c26e476b3b10c9ae5047e0f2941e9c019.tar.bz2 takahe-ea99f65c26e476b3b10c9ae5047e0f2941e9c019.zip |
Icon and image for Identity could be a list
Diffstat (limited to 'core')
-rw-r--r-- | core/ld.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -456,6 +456,20 @@ def parse_ld_date(value: str | None) -> datetime.datetime | None: ) +def get_first_image_url(data) -> str | None: + """ + 'icon' and 'image' fields might be a dict or a list. Return the first + 'url' for something that looks to be for an image. + """ + if isinstance(data, list): + for itm in data: + if isinstance(itm, dict) and "url" in itm: + return itm["url"] + elif isinstance(data, dict): + return data.get("url") + return None + + def media_type_from_filename(filename): _, extension = os.path.splitext(filename) if extension == ".png": |