mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🎈 perf(image_utils): 在image_utils中禁用代理下载 (#1710)
* 🎈 perf(image_utils): 在image_utils中禁用代理下载 get_download_image_hash使用场景是访问腾讯服务器获取图片,无需走代理 * ✨ Add optional proxy support to image hash download function
This commit is contained in:
parent
05f954eb8b
commit
54a93a2f54
@ -390,7 +390,7 @@ def get_img_hash(image_file: str | Path) -> str:
|
|||||||
return str(hash_value)
|
return str(hash_value)
|
||||||
|
|
||||||
|
|
||||||
async def get_download_image_hash(url: str, mark: str) -> str:
|
async def get_download_image_hash(url: str, mark: str, use_proxy: bool = False) -> str:
|
||||||
"""下载图片获取哈希值
|
"""下载图片获取哈希值
|
||||||
|
|
||||||
参数:
|
参数:
|
||||||
@ -402,7 +402,7 @@ async def get_download_image_hash(url: str, mark: str) -> str:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if await AsyncHttpx.download_file(
|
if await AsyncHttpx.download_file(
|
||||||
url, TEMP_PATH / f"compare_download_{mark}_img.jpg"
|
url, TEMP_PATH / f"compare_download_{mark}_img.jpg", use_proxy=use_proxy
|
||||||
):
|
):
|
||||||
img_hash = get_img_hash(TEMP_PATH / f"compare_download_{mark}_img.jpg")
|
img_hash = get_img_hash(TEMP_PATH / f"compare_download_{mark}_img.jpg")
|
||||||
return str(img_hash)
|
return str(img_hash)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user