mirror of
https://github.com/alantang1977/JunTV.git
synced 2024-12-05 00:33:10 +02:00
fix:ipv6 result
This commit is contained in:
parent
e5c236334b
commit
a764270848
1 changed files with 16 additions and 14 deletions
|
@ -1,12 +1,14 @@
|
|||
from aiohttp import ClientSession, TCPConnector
|
||||
from time import time
|
||||
import asyncio
|
||||
import re
|
||||
from utils.config import config
|
||||
import utils.constants as constants
|
||||
from utils.tools import is_ipv6, remove_cache_info, get_resolution_value, get_logger
|
||||
import subprocess
|
||||
from time import time
|
||||
|
||||
import yt_dlp
|
||||
from aiohttp import ClientSession, TCPConnector
|
||||
|
||||
import utils.constants as constants
|
||||
from utils.config import config
|
||||
from utils.tools import is_ipv6, remove_cache_info, get_resolution_value, get_logger
|
||||
|
||||
logger = get_logger(constants.log_path)
|
||||
|
||||
|
@ -42,9 +44,9 @@ async def get_speed_yt_dlp(url, timeout=config.sort_timeout):
|
|||
if "width" in info and "height" in info
|
||||
else None
|
||||
)
|
||||
return (fps, resolution)
|
||||
return fps, resolution
|
||||
except:
|
||||
return (float("inf"), None)
|
||||
return float("inf"), None
|
||||
|
||||
|
||||
async def get_speed_requests(url, timeout=config.sort_timeout, proxy=None):
|
||||
|
@ -144,7 +146,7 @@ async def check_stream_speed(url_info):
|
|||
if frame is None or frame == float("inf"):
|
||||
return float("inf")
|
||||
url_info[2] = resolution
|
||||
return (url_info, frame)
|
||||
return url_info, frame
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return float("inf")
|
||||
|
@ -155,7 +157,7 @@ speed_cache = {}
|
|||
|
||||
async def get_speed(url, ipv6_proxy=None, callback=None):
|
||||
"""
|
||||
Get the speed of the url
|
||||
Get the speed (response time and resolution) of the url
|
||||
"""
|
||||
try:
|
||||
cache_key = None
|
||||
|
@ -168,14 +170,14 @@ async def get_speed(url, ipv6_proxy=None, callback=None):
|
|||
if cache_key in speed_cache:
|
||||
return speed_cache[cache_key][0]
|
||||
if ipv6_proxy and url_is_ipv6:
|
||||
speed = 0
|
||||
speed = (0, None)
|
||||
else:
|
||||
speed = await get_speed_yt_dlp(url)
|
||||
if cache_key and cache_key not in speed_cache:
|
||||
speed_cache[cache_key] = speed
|
||||
return speed
|
||||
except:
|
||||
return float("inf")
|
||||
return float("inf"), None
|
||||
finally:
|
||||
if callback:
|
||||
callback()
|
||||
|
|
Loading…
Reference in a new issue