feat: optimize
This commit is contained in:
parent
2088729410
commit
bcbe03a677
@ -148,7 +148,7 @@ class MediaChunkHolder(object):
|
||||
|
||||
|
||||
class MediaChunkHolderManager(object):
|
||||
MAX_CACHE_SIZE = 2**32 # 4GB
|
||||
MAX_CACHE_SIZE = 2**31 # 2GB
|
||||
current_cache_size: int = 0
|
||||
# chunk unique id -> ChunkHolder
|
||||
disk_chunk_cache: diskcache.Cache
|
||||
|
@ -85,7 +85,7 @@ async def search_tg_file_list(body: TgToFileListRequestBody):
|
||||
chat_id = apiutils.get_message_chat_id_from_dict(msg_info)
|
||||
msg_id = apiutils.get_message_msg_id_from_dict(msg_info)
|
||||
msg_info["file_name"] = file_name
|
||||
msg_info["download_url"] = f"{param.base.exposed_url}/tg/api/v1/file/get/{chat_id}/{msg_id}/{file_name}"
|
||||
msg_info["download_url"] = f"{param.base.exposed_url}/tg/api/v1/file/get/{chat_id}/{msg_id}/{quote(file_name)}"
|
||||
msg_info["src_tg_link"] = f"https://t.me/c/{chat_id}/{msg_id}"
|
||||
res_dict.append(msg_info)
|
||||
|
||||
@ -127,7 +127,7 @@ async def get_tg_file_list(body: TgToFileListRequestBody):
|
||||
msg_info = json.loads(item.to_json())
|
||||
msg_info["file_name"] = file_name
|
||||
msg_info["download_url"] = (
|
||||
f"{param.base.exposed_url}/tg/api/v1/file/get/{body.chat_id}/{item.id}/{file_name}?sign={body.token}"
|
||||
f"{param.base.exposed_url}/tg/api/v1/file/get/{body.chat_id}/{item.id}/{quote(file_name)}?sign={body.token}"
|
||||
)
|
||||
res_dict.append(msg_info)
|
||||
|
||||
|
@ -39,7 +39,9 @@ async def link_convert(link: str) -> str:
|
||||
file_name = apiutils.get_message_media_name(msg)
|
||||
param = configParse.get_TgToFileSystemParameter()
|
||||
sign = clients_mgr.generate_sign(client.session_name, EnumSignLevel.VIST)
|
||||
url = f"{param.base.exposed_url}/tg/api/v1/file/get/{utils.get_peer_id(msg.peer_id)}/{msg.id}/{file_name}?sign={sign}"
|
||||
url = (
|
||||
f"{param.base.exposed_url}/tg/api/v1/file/get/{utils.get_peer_id(msg.peer_id)}/{msg.id}/{quote(file_name)}?sign={sign}"
|
||||
)
|
||||
return url
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user