Skip to content

Commit

Permalink
Merge pull request #792 from Guovin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Guovin authored Jan 6, 2025
2 parents f215afc + f6f32af commit 2caf001
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/speed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import http.cookies
import json
import re
import subprocess
Expand All @@ -13,6 +14,8 @@
from utils.config import config
from utils.tools import is_ipv6, remove_cache_info, get_resolution_value

http.cookies._is_legal_key = lambda _: True


async def get_speed_with_download(url: str, session: ClientSession = None, timeout: int = config.sort_timeout) -> dict[
str, float | None]:
Expand All @@ -30,8 +33,8 @@ async def get_speed_with_download(url: str, session: ClientSession = None, timeo
created_session = False
try:
async with session.get(url, timeout=timeout) as response:
if response.status == 404:
raise Exception("404")
if response.status != 200:
raise Exception("Invalid response")
info['delay'] = int(round((time() - start_time) * 1000))
async for chunk in response.content.iter_any():
if chunk:
Expand Down

0 comments on commit 2caf001

Please sign in to comment.