update
This commit is contained in:
parent
fb2edda4f2
commit
796a7854de
3 changed files with 6 additions and 4 deletions
|
@ -2,6 +2,7 @@ import traceback
|
|||
from typing import Union
|
||||
|
||||
import aiohttp
|
||||
from aiofile import async_open
|
||||
import filetype as ft
|
||||
from tenacity import retry, wait_fixed, stop_after_attempt
|
||||
|
||||
|
@ -60,8 +61,8 @@ async def download_to_cache(link: str) -> Union[str, bool]:
|
|||
res = await resp.read()
|
||||
ftt = ft.match(res).extension
|
||||
path = f'{random_cache_path()}.{ftt}'
|
||||
with open(path, 'wb+') as file:
|
||||
file.write(res)
|
||||
async with async_open(path, 'wb+') as file:
|
||||
await file.write(res)
|
||||
return path
|
||||
except:
|
||||
Logger.error(traceback.format_exc())
|
||||
|
|
|
@ -37,8 +37,8 @@ async def search_csr(id=None): # 根据 ChemSpider 的 ID 查询 ChemSpider 的
|
|||
if v.isdigit():
|
||||
value += int(v) # 加一起
|
||||
wh = 500 * value // 100
|
||||
if wh < 250:
|
||||
wh = 250
|
||||
if wh < 500:
|
||||
wh = 500
|
||||
return {'name': name, 'image': f'https://www.chemspider.com/ImagesHandler.ashx?id={answer}&w={wh}&h={wh}'}
|
||||
|
||||
|
||||
|
|
|
@ -18,3 +18,4 @@ feedparser
|
|||
ffmpy
|
||||
google_play_scraper
|
||||
py-cpuinfo
|
||||
aiofile
|
||||
|
|
Reference in a new issue