完善获取图片url的方法

This commit is contained in:
2025-12-20 22:42:04 +08:00
parent 481207d511
commit 92aa5be1c1

View File

@@ -70,7 +70,7 @@ def check_emoji(uuid: str, connection = connect_db()) -> bool:
logger.error(f"检查UUID失败: {uuid}, 错误: {e}")
return False
def get_emoji_content(uuid: str, content_index: str = 'url', connection = connect_db()) -> str | None:
def get_emoji_content(uuid: str, content_index: str, connection = connect_db()) -> str | None:
"""
获取图片信息,检查图片在 approved 库中检索 approved 是否为 1为 1 则返回获取到的索引内容
@@ -105,6 +105,22 @@ def get_emoji_content(uuid: str, content_index: str = 'url', connection = connec
logger.error(f"获取失败: {uuid}, 错误: {e}")
return None
def get_emoji_url(uuid: str) -> str:
"""
获取图片的 url
Args:
uuid: emoji 的UUID
Returns:
content: 获取到的图片的 url
"""
url = get_emoji_content(uuid, 'url')
if url is not None:
return url
return ''
if __name__ == "__main__":
record = check_emoji("ffe1663c-44e1-4719-a5ba-01485f70a87e")
print(record)
test_uuid = "c3151774-2c4c-48f6-a3ac-b8802cf95498"
print(check_emoji(test_uuid))
print(get_emoji_url(test_uuid))