Skip to content

Commit

Permalink
Merge pull request #707 from Guovin/master
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
Guovin authored Dec 19, 2024
2 parents e349fb3 + 5c8fa79 commit e58a2f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e58a2f2

Please sign in to comment.