Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #707

Merged
merged 2 commits into from
Dec 19, 2024
Merged

fix #707

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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