From 1416946bba292bf410be12229e0222257e2dfb5d Mon Sep 17 00:00:00 2001 From: XiaoYouChR Date: Wed, 20 Nov 2024 22:52:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B9=E6=B3=95=E4=B8=80?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E6=97=B6=E6=9C=89=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=87=BA=E7=8E=B0=E7=9A=84=E6=B2=A1=E6=9C=89=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=A7=A3=E7=A0=81=20url=E7=BC=96=E7=A0=81=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E5=B0=86=E6=96=B9=E6=B3=954?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E5=90=8D=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E6=94=B9=E4=B8=BAns=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=EF=BC=8C=E4=BB=A5=E8=A7=A3=E5=86=B3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?(#55)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/methods.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/common/methods.py b/app/common/methods.py index e022fc4..85dafb7 100644 --- a/app/common/methods.py +++ b/app/common/methods.py @@ -7,7 +7,7 @@ from datetime import datetime, timedelta, timezone from email.utils import decode_rfc2231 from functools import wraps -from time import sleep, localtime, time +from time import sleep, localtime, time_ns from urllib.parse import unquote, parse_qs, urlparse import httpx @@ -214,6 +214,7 @@ def getLinkInfo(url:str, headers:dict, fileName:str="", verify:bool=False, proxy match = re.search(r'filename\s*=\s*["\']?([^"\';]+)["\']?', headerValue, re.IGNORECASE) if match: fileName = match.group(1) + fileName = urllib.parse.unquote(fileName) # 移除文件名头尾可能存在的引号 if fileName: @@ -256,7 +257,7 @@ def getLinkInfo(url:str, headers:dict, fileName:str="", verify:bool=False, proxy # 什么都 Get 不到的情况 logger.info(f"获取文件名失败, 错误:{e}") content_type = head["content-type"].split('/')[-1] - fileName = f"downloaded_file{int(time())}.{content_type}" + fileName = f"downloaded_file{int(time_ns())}.{content_type}" logger.debug(f"方法4获取文件名成功, 文件名:{fileName}") return url, fileName, fileSize \ No newline at end of file