Update iptv流畅度检测.py

This commit is contained in:
frxz751113
2024-08-14 23:23:44 +08:00
committed by GitHub
parent 8cac2e75f9
commit 86b306dd25
+16 -17
View File
@@ -144,24 +144,23 @@ for url in valid_urls:
check_response = requests.get(urld, timeout=0.5) check_response = requests.get(urld, timeout=0.5)
if check_response.status_code != 200: if check_response.status_code != 200:
continue_parsing = False # 如果状态码不是200,设置标志为False,跳过当前JSON文件的解析 continue_parsing = False # 如果状态码不是200,设置标志为False,跳过当前JSON文件的解析
else:
continue # 如果continue_parsing为True,继续解析当前JSON文件
# 如果continue_parsing为True,继续解析当前JSON文件 if continue_parsing:
if continue_parsing: for line in lines:
for line in lines: if 'hls' in line and ('udp' not in line and 'rtp' not in line):
if 'hls' in line and ('udp' not in line and 'rtp' not in line): #行中需包含m3u,但排除udp和trp line = line.strip()
line = line.strip() if line:
if line: name, channel_url = line.split(',')
name, channel_url = line.split(',') urls = channel_url.split('/', 3)
urls = channel_url.split('/', 3) url_data = url.split('/')
url_data = json_url.split('/', 3) if len(urls) >= 4:
if len(urls) >= 4: urld = (f"{urls[0]}://{url_data[2]}/{urls[3]}")
urld = (f"{urls[0]}//{url_data[2]}/{urls[3]}") else:
else: urld = (f"{urls[0]}://{url_data[2]}")
urld = (f"{urls[0]}//{url_data[2]}") print(f"{name},{urld}")
print(f"{name},{urld}")
if name and urld: if name and urld:
name = name.replace("高清电影", "影迷电影") name = name.replace("高清电影", "影迷电影") # 修正了这里的缩进错误
name = name.replace("中央", "CCTV") name = name.replace("中央", "CCTV")
name = name.replace("高清", "") name = name.replace("高清", "")
name = name.replace("HD", "") name = name.replace("HD", "")