From 86b306dd25f26b4745b626304e64b3cd5f066e23 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Wed, 14 Aug 2024 23:23:44 +0800 Subject: [PATCH] =?UTF-8?q?Update=20iptv=E6=B5=81=E7=95=85=E5=BA=A6?= =?UTF-8?q?=E6=A3=80=E6=B5=8B.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/iptv流畅度检测.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/py/iptv流畅度检测.py b/py/iptv流畅度检测.py index d0d39f6..e1d1232 100644 --- a/py/iptv流畅度检测.py +++ b/py/iptv流畅度检测.py @@ -144,24 +144,23 @@ for url in valid_urls: check_response = requests.get(urld, timeout=0.5) if check_response.status_code != 200: continue_parsing = False # 如果状态码不是200,设置标志为False,跳过当前JSON文件的解析 - else: - continue - # 如果continue_parsing为True,继续解析当前JSON文件 - if continue_parsing: - for line in lines: - if 'hls' in line and ('udp' not in line and 'rtp' not in line): #行中需包含m3u,但排除udp和trp - line = line.strip() - if line: - name, channel_url = line.split(',') - urls = channel_url.split('/', 3) - url_data = json_url.split('/', 3) - if len(urls) >= 4: - urld = (f"{urls[0]}//{url_data[2]}/{urls[3]}") - else: - urld = (f"{urls[0]}//{url_data[2]}") - print(f"{name},{urld}") + + # 如果continue_parsing为True,继续解析当前JSON文件 + if continue_parsing: + for line in lines: + if 'hls' in line and ('udp' not in line and 'rtp' not in line): + line = line.strip() + if line: + name, channel_url = line.split(',') + urls = channel_url.split('/', 3) + url_data = url.split('/') + if len(urls) >= 4: + urld = (f"{urls[0]}://{url_data[2]}/{urls[3]}") + else: + urld = (f"{urls[0]}://{url_data[2]}") + print(f"{name},{urld}") if name and urld: - name = name.replace("高清电影", "影迷电影") + name = name.replace("高清电影", "影迷电影") # 修正了这里的缩进错误 name = name.replace("中央", "CCTV") name = name.replace("高清", "") name = name.replace("HD", "")