fix:sort infinite waiting(#705)
This commit is contained in:
parent
2e6e31e223
commit
9d569c9991
@ -48,7 +48,7 @@ async def get_speed_m3u8(url: str, timeout: int = config.sort_timeout) -> dict[s
|
||||
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'):
|
||||
if response.headers.get('Content-Type') == 'application/vnd.apple.mpegurl':
|
||||
m3u8_obj = m3u8.load(url, timeout=2)
|
||||
speed_list = []
|
||||
start_time = time()
|
||||
@ -61,6 +61,9 @@ async def get_speed_m3u8(url: str, timeout: int = config.sort_timeout) -> dict[s
|
||||
if info['delay'] is None and download_info['delay'] is not None:
|
||||
info['delay'] = download_info['delay']
|
||||
info['speed'] = sum(speed_list) / len(speed_list) if speed_list else 0
|
||||
elif response.headers.get('Content-Length'):
|
||||
download_info = await get_speed_with_download(url, timeout)
|
||||
info.update(download_info)
|
||||
else:
|
||||
return info
|
||||
except:
|
||||
@ -193,8 +196,6 @@ 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 '/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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user