Skip to content

Commit

Permalink
chore:speed filter inf
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Sep 10, 2024
1 parent f2be827 commit f695ee2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions utils/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ async def get_speed_by_info(url_info, ffmpeg, semaphore, callback=None):
url = quote(url, safe=":/?&=$[]")
url_info[0] = url
if cache_key in speed_cache:
return (tuple(url_info), speed_cache[cache_key])
speed = speed_cache[cache_key]
return (tuple(url_info), speed) if speed != float("inf") else float("inf")
try:
if ".m3u8" not in url and ffmpeg:
speed = await check_stream_speed(url_info)
Expand Down Expand Up @@ -163,11 +164,7 @@ async def sort_urls_by_speed_and_resolution(data, ffmpeg=False, callback=None):
for url_info in data
)
)
valid_response = [
res
for res in response
if (isinstance(res, tuple) and res[1] != float("inf")) or (res != float("inf"))
]
valid_response = [res for res in response if res != float("inf")]

def extract_resolution(resolution_str):
numbers = re.findall(r"\d+x\d+", resolution_str)
Expand Down

0 comments on commit f695ee2

Please sign in to comment.