Update iptv流畅度检测.py
This commit is contained in:
+12
-9
@@ -51,7 +51,8 @@ for province_isp in provinces_isps:
|
|||||||
print(f"文件 '{province_isp}.txt' 不存在. 跳过此文件.")
|
print(f"文件 '{province_isp}.txt' 不存在. 跳过此文件.")
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
province, isp, mcast = keyword.split("_")
|
province, isp, mcast = keyword.split("_")
|
||||||
#将省份转成英文小写
|
isp_en = None # 初始化isp_en
|
||||||
|
org = None # 初始化org
|
||||||
# 根据不同的 isp 设置不同的 org 值
|
# 根据不同的 isp 设置不同的 org 值
|
||||||
if province == "北京" and isp == "联通":
|
if province == "北京" and isp == "联通":
|
||||||
isp_en = "cucc"
|
isp_en = "cucc"
|
||||||
@@ -60,15 +61,16 @@ for keyword in keywords:
|
|||||||
isp_en = "cucc"
|
isp_en = "cucc"
|
||||||
org = "CHINA UNICOM China169 Backbone"
|
org = "CHINA UNICOM China169 Backbone"
|
||||||
elif isp == "电信":
|
elif isp == "电信":
|
||||||
org = "Chinanet"
|
|
||||||
isp_en = "ctcc"
|
isp_en = "ctcc"
|
||||||
|
org = "Chinanet"
|
||||||
elif isp == "移动":
|
elif isp == "移动":
|
||||||
org == "China Mobile communications corporation"
|
|
||||||
isp_en = "cmcc"
|
isp_en = "cmcc"
|
||||||
|
org = "China Mobile communications corporation"
|
||||||
|
|
||||||
current_time = datetime.now()
|
current_time = datetime.datetime.now()
|
||||||
timeout_cnt = 0
|
timeout_cnt = 0
|
||||||
result_urls = set()
|
result_urls = set()
|
||||||
|
|
||||||
while len(result_urls) == 0 and timeout_cnt <= 5:
|
while len(result_urls) == 0 and timeout_cnt <= 5:
|
||||||
try:
|
try:
|
||||||
search_url = 'https://fofa.info/result?qbase64='
|
search_url = 'https://fofa.info/result?qbase64='
|
||||||
@@ -125,14 +127,15 @@ for keyword in keywords:
|
|||||||
new_data = data.replace("rtp://", f"{url}/rtp/")
|
new_data = data.replace("rtp://", f"{url}/rtp/")
|
||||||
new_file.write(new_data)
|
new_file.write(new_data)
|
||||||
print(f'已生成播放列表,保存至{txt_filename}')
|
print(f'已生成播放列表,保存至{txt_filename}')
|
||||||
|
break # 如果找到有效IP,退出循环
|
||||||
|
|
||||||
except (requests.Timeout, requests.RequestException) as e:
|
except (requests.Timeout, requests.RequestException) as e:
|
||||||
timeout_cnt += 1
|
timeout_cnt += 1 # 更新超时计数
|
||||||
print(f"{current_time} [{province}]搜索请求发生超时,异常次数:{timeout_cnt}")
|
print(f"{current_time} [{province}]搜索请求发生超时,异常次数:{timeout_cnt}")
|
||||||
if timeout_cnt <= 2:
|
if timeout_cnt > 5: # 如果超过5次超时,退出循环
|
||||||
# 继续下一次循环迭代
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
print(f"{current_time} 搜索IPTV频道源[],超时次数过多:{timeout_cnt} 次,停止处理")
|
print(f"{current_time} 搜索IPTV频道源[],超时次数过多:{timeout_cnt} 次,停止处理")
|
||||||
|
break
|
||||||
|
|
||||||
print('节目表制作完成! 文件输出在当前文件夹!')
|
print('节目表制作完成! 文件输出在当前文件夹!')
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user