From 252acaf864a04cbed66701a82a810f74a3d92c66 Mon Sep 17 00:00:00 2001 From: "guorong.zheng" <360996299@qq.com> Date: Mon, 11 Nov 2024 15:58:31 +0800 Subject: [PATCH 1/2] feat:ipv6 test --- utils/channel.py | 7 +------ utils/config.py | 6 ++++++ utils/constants.py | 2 ++ utils/speed.py | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/utils/channel.py b/utils/channel.py index 88e02728e5f..79e83b5cfd6 100644 --- a/utils/channel.py +++ b/utils/channel.py @@ -643,12 +643,7 @@ async def process_sort_channel_list(data, ipv6=False, callback=None): """ Processs the sort channel list """ - open_ipv6 = ( - "ipv6" in config.ipv_type - or "all" in config.ipv_type - or "全部" in config.ipv_type - ) - ipv6_proxy = None if not open_ipv6 or ipv6 else "http://www.ipv6proxy.net/go.php?u=" + ipv6_proxy = None if (not config.open_ipv6 or ipv6) else constants.ipv6_proxy ffmpeg_installed = is_ffmpeg_installed() if config.open_ffmpeg and not ffmpeg_installed: print("FFmpeg is not installed, using requests for sorting.") diff --git a/utils/config.py b/utils/config.py index 87a5cd07c7a..ea711309fff 100644 --- a/utils/config.py +++ b/utils/config.py @@ -60,6 +60,12 @@ def open_filter_resolution(self): def ipv_type(self): return self.config.get("Settings", "ipv_type", fallback="全部").lower() + @property + def open_ipv6(self): + return ( + "ipv6" in self.ipv_type or "all" in self.ipv_type or "全部" in self.ipv_type + ) + @property def ipv_type_prefer(self): return [ diff --git a/utils/constants.py b/utils/constants.py index 1b1a95a706c..77ae7a49e86 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -58,3 +58,5 @@ "subscribe": "订阅源", "online_search": "关键字源", } + +ipv6_proxy = "http://www.ipv6proxy.net/go.php?u=" diff --git a/utils/speed.py b/utils/speed.py index 2b048787604..cb6562d5761 100644 --- a/utils/speed.py +++ b/utils/speed.py @@ -142,8 +142,9 @@ async def get_speed_by_info( return float("inf") try: if ipv6_proxy and url_is_ipv6: - url = ipv6_proxy + url - if ffmpeg: + url_speed = 0 + speed = (url_info, url_speed) + elif ffmpeg: speed = await check_stream_speed(url_info) url_speed = speed[1] if speed != float("inf") else float("inf") if url_speed == float("inf"): @@ -160,7 +161,7 @@ async def get_speed_by_info( speed[0][0] = add_url_info(speed[0][0], url_show_info) speed = (tuple(speed[0]), speed[1]) return speed - except Exception: + except: return float("inf") finally: if callback: From 6505bddecc27c18edbb1b105c2071240f2fc3725 Mon Sep 17 00:00:00 2001 From: "guorong.zheng" <360996299@qq.com> Date: Mon, 11 Nov 2024 16:12:05 +0800 Subject: [PATCH 2/2] chore:clean log --- main.py | 3 +-- utils/channel.py | 4 ++-- utils/constants.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 736174122b5..c0a31bfa937 100644 --- a/main.py +++ b/main.py @@ -204,6 +204,7 @@ async def main(self): else "result.log" ) update_file(user_log_file, "output/result_new.log", copy=True) + cleanup_logging() convert_to_m3u() total_time = format_interval(time() - main_start_time) print( @@ -227,8 +228,6 @@ async def main(self): run_service() except asyncio.exceptions.CancelledError: print("Update cancelled!") - finally: - cleanup_logging() async def start(self, callback=None): def default_callback(self, *args, **kwargs): diff --git a/utils/channel.py b/utils/channel.py index 79e83b5cfd6..78b6655462c 100644 --- a/utils/channel.py +++ b/utils/channel.py @@ -34,8 +34,8 @@ def setup_logging(): Setup logging """ global handler - if not os.path.exists(constants.log_dir): - os.makedirs(constants.log_dir) + if not os.path.exists(constants.output_dir): + os.makedirs(constants.output_dir) handler = RotatingFileHandler(constants.log_path, encoding="utf-8") logging.basicConfig( handlers=[handler], diff --git a/utils/constants.py b/utils/constants.py index 77ae7a49e86..53028673b33 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -1,10 +1,10 @@ import os -log_dir = "output" +output_dir = "output" log_file = "result_new.log" -log_path = os.path.join(log_dir, log_file) +log_path = os.path.join(output_dir, log_file) url_pattern = r"((https?):\/\/)?(\[[0-9a-fA-F:]+\]|([\w-]+\.)+[\w-]+)(:[0-9]{1,5})?(\/[^\s]*)?(\$[^\s]+)?"