Merge pull request from Guovin/dev

FIx
This commit is contained in:
Govin 2024-12-18 11:44:16 +08:00 committed by GitHub
commit e1c8a57a50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions
tkinter_ui
utils

@ -457,6 +457,7 @@ class DefaultUI:
"open_request_checkbutton",
"open_driver_checkbutton",
"open_proxy_checkbutton",
"request_timeout_entry",
"source_file_entry",
"source_file_button",
"final_file_entry",

@ -35,8 +35,8 @@ async def get_speed_with_download(url: str, timeout: int = config.sort_timeout)
finally:
end_time = time()
total_time += end_time - start_time
info['speed'] = (total_size / total_time if total_time > 0 else 0) / 1024 / 1024
return info
info['speed'] = (total_size / total_time if total_time > 0 else 0) / 1024 / 1024
return info
async def get_speed_m3u8(url: str, timeout: int = config.sort_timeout) -> dict[str, float | None]:
@ -45,7 +45,7 @@ async def get_speed_m3u8(url: str, timeout: int = config.sort_timeout) -> dict[s
"""
info = {'speed': None, 'delay': None}
try:
url = quote(url, safe=':/?$&=@').partition('$')[0]
url = quote(url, safe=':/?$&=@[]').partition('$')[0]
async with ClientSession(connector=TCPConnector(ssl=False), trust_env=True) as session:
async with session.head(url, timeout=2) as response:
if response.headers.get('Content-Length'):
@ -193,10 +193,10 @@ async def get_speed(url, ipv6_proxy=None, callback=None):
if ipv6_proxy and url_is_ipv6:
data['speed'] = float("inf")
data['delay'] = float("-inf")
elif '.m3u8' in url:
data.update(await get_speed_m3u8(url))
else:
elif '/rtp/' in url:
data.update(await get_speed_with_download(url))
else:
data.update(await get_speed_m3u8(url))
if cache_key and cache_key not in cache:
cache[cache_key] = data
return data