Update 酒店源.py
This commit is contained in:
@@ -31,13 +31,10 @@ from translate import Translator # 导入Translator类,用于文本翻译
|
|||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
urls = [
|
urls = [
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJIZW5hbiI=",#河南#
|
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJndWFuZ2Rvbmci",#广东
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJndWFuZ2Rvbmci",#广东#
|
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJIdW5hbiI%3D",#湖南
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJndWFuZ3hpIg==",#广西#
|
"https://fofa.info/result?qbase64=Ym9keT0i5pm65oWn5YWJ6L%2BFIg%3D%3D",#body="智慧光迅"
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJsaWFvbmluZyI=",#辽宁#
|
"https://fofa.info/result?qbase64=c2VydmVyPSJuZ2lueCI%3D",#河南#
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJoZWlsb25namlhbmci",#黑龙江#
|
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJzaGFueGki",#山西#
|
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJ6aGVqaWFuZyI=",#浙江#
|
|
||||||
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJoZWJlaSI%3D",#河北#
|
"https://fofa.info/result?qbase64=IlpIR1hUViIgJiYgcmVnaW9uPSJoZWJlaSI%3D",#河北#
|
||||||
]
|
]
|
||||||
#定义网址替换规则
|
#定义网址替换规则
|
||||||
@@ -115,53 +112,148 @@ for url in urls:
|
|||||||
valid_urls.append(result)
|
valid_urls.append(result)
|
||||||
for url in valid_urls:
|
for url in valid_urls:
|
||||||
print(url)
|
print(url)
|
||||||
# 定义替换IP和端口的函数
|
# 遍历网址列表,获取JSON文件并解析
|
||||||
def replace_ip_and_port(json_line, new_ip, new_port):
|
for url in valid_urls:
|
||||||
# 使用正则表达式替换行中的IP地址和端口
|
|
||||||
ip_port_pattern = r"http://(\d+\.\d+\.\d+\.\d+):(\d+)"
|
|
||||||
def replace(match):
|
|
||||||
return f"http://{new_ip}:{new_port}"
|
|
||||||
return re.sub(ip_port_pattern, replace, json_line)
|
|
||||||
|
|
||||||
# 读取原始JSON数据
|
|
||||||
def read_json_data(json_url):
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(json_url, timeout=1)
|
# 发送GET请求获取JSON文件,设置超时时间为0.5秒
|
||||||
response.raise_for_status() # 检查请求是否成功
|
json_url = f"{url}"
|
||||||
return response.text
|
response = requests.get(json_url, timeout=1)################################
|
||||||
except requests.exceptions.RequestException as e:
|
json_data = response.content.decode('utf-8')
|
||||||
print(f"Error fetching the JSON data: {e}")
|
try:
|
||||||
return None
|
# 按行分割数据
|
||||||
|
lines = json_data.split('\n')
|
||||||
# 写入替换后的JSON数据到新文件
|
|
||||||
def write_to_new_file(new_file_path, new_json_lines):
|
|
||||||
with open(new_file_path, 'w', encoding='utf-8') as file:
|
|
||||||
for line in new_json_lines:
|
|
||||||
file.write(line + '\n')
|
|
||||||
|
|
||||||
# 主逻辑
|
|
||||||
for json_url in valid_urls:
|
|
||||||
original_json_data = read_json_data(json_url)
|
|
||||||
if original_json_data:
|
|
||||||
# 假设JSON数据是按行分隔的字符串
|
|
||||||
lines = original_json_data.strip().split('\n')
|
|
||||||
# 遍历所有行并替换IP和端口
|
|
||||||
new_json_lines = []
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
for valid_url in valid_urls:
|
if 'hls' in line and ('udp' not in line or 'rtp' not in line): #行中需包含m3u,但排除udp和trp
|
||||||
new_ip = valid_url.split('/')[2] # 提取IP地址
|
line = line.strip()
|
||||||
new_port = valid_url.split(':')[-1].split('/')[0] # 提取端口号
|
if line:
|
||||||
new_line = replace_ip_and_port(line, new_ip, new_port)
|
name, channel_url = line.split(',')
|
||||||
new_json_lines.append(new_line)
|
urls = channel_url.split('/', 3)
|
||||||
# 将替换后的行写入新文件
|
url_data = json_url.split('/', 3)
|
||||||
write_to_new_file('iptv.txt', new_json_lines)
|
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("中央", "CCTV")
|
||||||
|
name = name.replace("高清", "")
|
||||||
|
name = name.replace("HD", "")
|
||||||
|
name = name.replace("标清", "")
|
||||||
|
name = name.replace("超高", "")
|
||||||
|
name = name.replace("频道", "")
|
||||||
|
name = name.replace("靓妆", "女性时尚")
|
||||||
|
name = name.replace("本港台", "TVB星河")
|
||||||
|
name = name.replace("汉3", "汉")
|
||||||
|
name = name.replace("汉4", "汉")
|
||||||
|
name = name.replace("汉5", "汉")
|
||||||
|
name = name.replace("汉6", "汉")
|
||||||
|
name = name.replace("CHC动", "动")
|
||||||
|
name = name.replace("CHC家", "家")
|
||||||
|
name = name.replace("CHC影", "影")
|
||||||
|
name = name.replace("-", "")
|
||||||
|
name = name.replace(" ", "")
|
||||||
|
name = name.replace("PLUS", "+")
|
||||||
|
name = name.replace("+", "+")
|
||||||
|
name = name.replace("(", "")
|
||||||
|
name = name.replace(")", "")
|
||||||
|
name = name.replace("L", "")
|
||||||
|
name = name.replace("新农村", "河南新农村")
|
||||||
|
name = name.replace("百姓调解", "河南百姓调解")
|
||||||
|
name = name.replace("法治", "河南法治")
|
||||||
|
name = name.replace("睛彩中原", "河南睛彩")
|
||||||
|
name = name.replace("军事", "河南军事")
|
||||||
|
name = name.replace("梨园", "河南梨园")
|
||||||
|
name = name.replace("相声小品", "河南相声小品")
|
||||||
|
name = name.replace("移动戏曲", "河南移动戏曲")
|
||||||
|
name = name.replace("都市生活", "河南都市生活")
|
||||||
|
name = name.replace("民生", "河南民生")
|
||||||
|
name = name.replace("CCTVNEWS", "CCTV13")
|
||||||
|
name = name.replace("cctv", "CCTV")
|
||||||
|
name = re.sub(r"CCTV(\d+)台", r"CCTV\1", name)
|
||||||
|
name = name.replace("CCTV1综合", "CCTV1")
|
||||||
|
name = name.replace("CCTV2财经", "CCTV2")
|
||||||
|
name = name.replace("CCTV3综艺", "CCTV3")
|
||||||
|
name = name.replace("CCTV4国际", "CCTV4")
|
||||||
|
name = name.replace("CCTV4中文国际", "CCTV4")
|
||||||
|
name = name.replace("CCTV4欧洲", "CCTV4")
|
||||||
|
name = name.replace("CCTV5体育", "CCTV5")
|
||||||
|
name = name.replace("CCTV5+体育", "CCTV5+")
|
||||||
|
name = name.replace("CCTV6电影", "CCTV6")
|
||||||
|
name = name.replace("CCTV7军事", "CCTV7")
|
||||||
|
name = name.replace("CCTV7军农", "CCTV7")
|
||||||
|
name = name.replace("CCTV7农业", "CCTV7")
|
||||||
|
name = name.replace("CCTV7国防军事", "CCTV7")
|
||||||
|
name = name.replace("CCTV8电视剧", "CCTV8")
|
||||||
|
name = name.replace("CCTV8纪录", "CCTV9")
|
||||||
|
name = name.replace("CCTV9记录", "CCTV9")
|
||||||
|
name = name.replace("CCTV9纪录", "CCTV9")
|
||||||
|
name = name.replace("CCTV10科教", "CCTV10")
|
||||||
|
name = name.replace("CCTV11戏曲", "CCTV11")
|
||||||
|
name = name.replace("CCTV12社会与法", "CCTV12")
|
||||||
|
name = name.replace("CCTV13新闻", "CCTV13")
|
||||||
|
name = name.replace("CCTV新闻", "CCTV13")
|
||||||
|
name = name.replace("CCTV14少儿", "CCTV14")
|
||||||
|
name = name.replace("央视14少儿", "CCTV14")
|
||||||
|
name = name.replace("CCTV少儿超", "CCTV14")
|
||||||
|
name = name.replace("CCTV15音乐", "CCTV15")
|
||||||
|
name = name.replace("CCTV音乐", "CCTV15")
|
||||||
|
name = name.replace("CCTV16奥林匹克", "CCTV16")
|
||||||
|
name = name.replace("SCTV5四川影视)", "SCTV5")
|
||||||
|
name = name.replace("CCTV17农业农村", "CCTV17")
|
||||||
|
name = name.replace("CCTV17军农", "CCTV17")
|
||||||
|
name = name.replace("CCTV17农业", "CCTV17")
|
||||||
|
name = name.replace("CCTV5+体育赛视", "CCTV5+")
|
||||||
|
name = name.replace("CCTV5+赛视", "CCTV5+")
|
||||||
|
name = name.replace("CCTV5+体育赛事", "CCTV5+")
|
||||||
|
name = name.replace("CCTV5+赛事", "CCTV5+")
|
||||||
|
name = name.replace("CCTV5+体育", "CCTV5+")
|
||||||
|
name = name.replace("CCTV5赛事", "CCTV5+")
|
||||||
|
name = name.replace("凤凰中文台", "凤凰中文")
|
||||||
|
name = name.replace("凤凰资讯台", "凤凰资讯")
|
||||||
|
name = name.replace("CCTV4K测试)", "CCTV4")
|
||||||
|
name = name.replace("CCTV164K", "CCTV16")
|
||||||
|
name = name.replace("上海东方卫视", "上海卫视")
|
||||||
|
name = name.replace("东方卫视", "上海卫视")
|
||||||
|
name = name.replace("内蒙卫视", "内蒙古卫视")
|
||||||
|
name = name.replace("福建东南卫视", "东南卫视")
|
||||||
|
name = name.replace("广东南方卫视", "南方卫视")
|
||||||
|
name = name.replace("湖南金鹰卡通", "金鹰卡通")
|
||||||
|
name = name.replace("炫动卡通", "哈哈炫动")
|
||||||
|
name = name.replace("卡酷卡通", "卡酷少儿")
|
||||||
|
name = name.replace("卡酷动画", "卡酷少儿")
|
||||||
|
name = name.replace("BRTVKAKU少儿", "卡酷少儿")
|
||||||
|
name = name.replace("优曼卡通", "优漫卡通")
|
||||||
|
name = name.replace("优曼卡通", "优漫卡通")
|
||||||
|
name = name.replace("嘉佳卡通", "佳嘉卡通")
|
||||||
|
name = name.replace("世界地理", "地理世界")
|
||||||
|
name = name.replace("CCTV世界地理", "地理世界")
|
||||||
|
name = name.replace("BTV北京卫视", "北京卫视")
|
||||||
|
name = name.replace("BTV冬奥纪实", "冬奥纪实")
|
||||||
|
name = name.replace("东奥纪实", "冬奥纪实")
|
||||||
|
name = name.replace("卫视台", "卫视")
|
||||||
|
name = name.replace("湖南电视台", "湖南卫视")
|
||||||
|
name = name.replace("少儿科教", "少儿")
|
||||||
|
name = name.replace("TV星河2)", "星河")
|
||||||
|
name = name.replace("影视剧", "影视")
|
||||||
|
name = name.replace("电视剧", "影视")
|
||||||
|
name = name.replace("奥运匹克", "")
|
||||||
|
results.append(f"{name},{urld}")
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
channels = []
|
||||||
|
for result in results:
|
||||||
|
line = result.strip()
|
||||||
|
if result:
|
||||||
|
channel_name, channel_url = result.split(',')
|
||||||
|
channels.append((channel_name, channel_url))
|
||||||
|
with open("iptv.txt", 'w', encoding='utf-8') as file:
|
||||||
|
for result in results:
|
||||||
|
file.write(result + "\n")
|
||||||
|
print(result)
|
||||||
print("频道列表文件iptv.txt获取完成!")
|
print("频道列表文件iptv.txt获取完成!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for line in fileinput.input("iptv.txt", inplace=True): #打开文件,并对其进行关键词原地替换
|
for line in fileinput.input("iptv.txt", inplace=True): #打开文件,并对其进行关键词原地替换
|
||||||
line = line.replace("河南河南", "河南")
|
line = line.replace("河南河南", "河南")
|
||||||
line = line.replace("河南河南", "河南")
|
line = line.replace("河南河南", "河南")
|
||||||
@@ -188,14 +280,18 @@ for line in fileinput.input("iptv.txt", inplace=True): #打开文件,并对其
|
|||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
#定义智慧桌面采集地址
|
#定义智慧桌面采集地址
|
||||||
urls = [
|
urls = [
|
||||||
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgcG9ydD0iMTExMSI%3D", # 1111
|
||||||
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgcG9ydD0iODA5NiI%3D", #8096
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5rKz5YyXIg%3D%3D", #河北
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5rKz5YyXIg%3D%3D", #河北
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5bm%2F5LicIg%3D%3D", #广东
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5bm%2F5LicIg%3D%3D", #广东
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5rKz5Y2XIg%3D%3D", # 河南
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5rKz5Y2XIg%3D%3D", # 河南
|
||||||
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgcmVnaW9uPSJIdWJlaSIg",#湖北
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgcG9ydD0iODE4MSIgJiYgY2l0eT0iR3VpZ2FuZyI%3D", #贵港8181
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgcG9ydD0iODE4MSIgJiYgY2l0eT0iR3VpZ2FuZyI%3D", #贵港8181
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY2l0eT0ieXVsaW4i",#玉林
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY2l0eT0ieXVsaW4i",#玉林
|
||||||
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0i5bm%2F6KW%2FIg%3D%3D", #广西 壮族iptv
|
||||||
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0ibGlhb25pbmci", # Liaoning (辽宁)
|
"https://fofa.info/result?qbase64=ImlwdHYvbGl2ZS96aF9jbi5qcyIgJiYgY291bnRyeT0iQ04iICYmIHJlZ2lvbj0ibGlhb25pbmci", # Liaoning (辽宁)
|
||||||
]
|
]
|
||||||
def modify_urls(url): #网址替换规则http://ip:port/iptv/live/1000.json?key=txiptv
|
def modify_urls(url):
|
||||||
modified_urls = []
|
modified_urls = []
|
||||||
ip_start_index = url.find("//") + 2
|
ip_start_index = url.find("//") + 2
|
||||||
ip_end_index = url.find(":", ip_start_index)
|
ip_end_index = url.find(":", ip_start_index)
|
||||||
@@ -210,7 +306,7 @@ def modify_urls(url): #网址替换规则http://ip:port/iptv/live/1000.json?key
|
|||||||
return modified_urls
|
return modified_urls
|
||||||
def is_url_accessible(url):
|
def is_url_accessible(url):
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=3) #//////////////////
|
response = requests.get(url, timeout=1) #//////////////////
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
return url
|
return url
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
@@ -267,22 +363,18 @@ for url in urls:
|
|||||||
valid_urls.append(result)
|
valid_urls.append(result)
|
||||||
for url in valid_urls:
|
for url in valid_urls:
|
||||||
print(url)
|
print(url)
|
||||||
# 遍历有效的URL列表,这些URL指向包含JSON数据的资源
|
# 遍历网址列表,获取JSON文件并解析
|
||||||
for url in valid_urls:
|
for url in valid_urls:
|
||||||
try:
|
try:
|
||||||
# 从当前URL中提取基础URL和IP地址
|
# 发送GET请求获取JSON文件,设置超时时间为0.5秒
|
||||||
# 假设URL格式为 http://或https://后跟IP地址,然后是其他部分
|
ip_start_index = url.find("//") + 2
|
||||||
ip_start_index = url.find("//") + 2 # 找到"//"后的第一个字符的索引
|
ip_dot_start = url.find(".") + 1
|
||||||
ip_dot_start = url.find(".") + 1 # 找到第一个"."后的第一个字符的索引
|
ip_index_second = url.find("/", ip_dot_start)
|
||||||
ip_index_second = url.find("/", ip_dot_start) # 从IP地址后的第一个"/"开始
|
base_url = url[:ip_start_index] # http:// or https://
|
||||||
base_url = url[:ip_start_index] # 提取基础URL部分,如http://或https://
|
ip_address = url[ip_start_index:ip_index_second]
|
||||||
ip_address = url[ip_start_index:ip_index_second] # 提取IP地址部分
|
|
||||||
# 构造一个新的基础URL,用于后续拼接
|
|
||||||
url_x = f"{base_url}{ip_address}"
|
url_x = f"{base_url}{ip_address}"
|
||||||
# 这里似乎是一个错误,json_url应该使用url_x,但代码中使用了原始的url
|
|
||||||
json_url = f"{url}"
|
json_url = f"{url}"
|
||||||
response = requests.get(json_url, timeout=3) # 发送GET请求到json_url,获取JSON格式的数据,设置超时时间为3秒
|
response = requests.get(json_url, timeout=1) #///////////////
|
||||||
# 将响应的内容解析为JSON格式
|
|
||||||
json_data = response.json()
|
json_data = response.json()
|
||||||
try:
|
try:
|
||||||
# 解析JSON文件,获取name和url字段
|
# 解析JSON文件,获取name和url字段
|
||||||
@@ -414,31 +506,24 @@ for url in urls:
|
|||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
# 初始化一个空列表,用于存储频道信息
|
|
||||||
channels = []
|
channels = []
|
||||||
# 遍历结果列表,每个结果代表一行数据
|
|
||||||
for result in results:
|
for result in results:
|
||||||
# 去除每行数据首尾的空白字符
|
|
||||||
line = result.strip()
|
line = result.strip()
|
||||||
try:
|
try:
|
||||||
# 尝试使用逗号分割字符串,分割一次,返回一个包含两部分的元组
|
# 尝试分割字符串,如果格式不正确则引发 ValueError
|
||||||
channel_name, channel_url = line.split(',', 1)
|
channel_name, channel_url = line.split(',', 1) # 使用逗号分割一次
|
||||||
# 如果分割成功,将频道名称和频道URL作为元组添加到channels列表中
|
|
||||||
channels.append((channel_name, channel_url))
|
channels.append((channel_name, channel_url))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# 如果分割失败,即数据格式不正确,打印错误信息并跳过当前行
|
# 如果发生 ValueError 则打印错误信息并跳过该行
|
||||||
print(f"跳过无法解析的行: {line}")
|
print(f"跳过无法解析的行: {line}")
|
||||||
# 使用with语句打开"iptv.txt"文件,以追加模式'a'写入,指定文件编码为'utf-8'
|
# 打开文本文件以追加的形式写入
|
||||||
with open("iptv.txt", 'a', encoding='utf-8') as file:
|
with open("iptv.txt", 'a', encoding='utf-8') as file:
|
||||||
# 遍历channels列表,列表中的每个元素都是一个包含频道名称和URL的元组
|
|
||||||
for channel_name, channel_url in channels:
|
for channel_name, channel_url in channels:
|
||||||
# 将频道名称和URL写入文件,以逗号分隔,后跟换行符
|
|
||||||
file.write(f"{channel_name},{channel_url}\n")
|
file.write(f"{channel_name},{channel_url}\n")
|
||||||
|
|
||||||
# 打印成功信息,告知用户频道列表已成功追加写入到文件中
|
|
||||||
print("频道列表文件iptv.txt追加写入成功!")
|
print("频道列表文件iptv.txt追加写入成功!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
###################################################去除列表中的组播地址,酒店源验证整理
|
###################################################去除列表中的组播地址,酒店源验证整理
|
||||||
def filter_lines(input_file, output_file):
|
def filter_lines(input_file, output_file):
|
||||||
@@ -625,7 +710,7 @@ with open(output_file_path, 'w', encoding='utf-8') as output_file:
|
|||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
# 尝试捕获5秒内的帧
|
# 尝试捕获5秒内的帧
|
||||||
while frame_count < 150 and (time.time() - start_time) < 10:#//////////////////////////////////////////////////////////////////////////////////////###########
|
while frame_count < 200 and (time.time() - start_time) < 10:#//////////////////////////////////////////////////////////////////////////////////////###########
|
||||||
ret, frame = cap.read()
|
ret, frame = cap.read()
|
||||||
if not ret:
|
if not ret:
|
||||||
break
|
break
|
||||||
@@ -633,7 +718,7 @@ with open(output_file_path, 'w', encoding='utf-8') as output_file:
|
|||||||
# 释放资源
|
# 释放资源
|
||||||
cap.release()
|
cap.release()
|
||||||
# 根据捕获的帧数判断状态并记录结果#////////////////////////////////////////////////////////////////////////////////////////////////////////////////###########
|
# 根据捕获的帧数判断状态并记录结果#////////////////////////////////////////////////////////////////////////////////////////////////////////////////###########
|
||||||
if frame_count >= 150: #5秒内超过100帧则写入#/////////////////////////////////////////////////////////////////////////////////////////////////////###########
|
if frame_count >= 200: #5秒内超过100帧则写入#/////////////////////////////////////////////////////////////////////////////////////////////////////###########
|
||||||
detected_ips[ip_key] = {'status': 'ok'}
|
detected_ips[ip_key] = {'status': 'ok'}
|
||||||
output_file.write(line) # 写入检测通过的行
|
output_file.write(line) # 写入检测通过的行
|
||||||
else:
|
else:
|
||||||
@@ -897,7 +982,7 @@ for line in lines:
|
|||||||
with open('酒店优选.txt', 'w', encoding="utf-8") as file:
|
with open('酒店优选.txt', 'w', encoding="utf-8") as file:
|
||||||
file.writelines(unique_lines)
|
file.writelines(unique_lines)
|
||||||
#任务结束,删除不必要的过程文件
|
#任务结束,删除不必要的过程文件
|
||||||
files_to_remove = ['去重.txt', "2.txt", "iptv#.txt", "e.txt", "a0.txt", "a.txt", "a1.txt", "b.txt", "c.txt", "c1.txt", "c2.txt", "d.txt", "f.txt", "o1.txt", "o.txt", "酒店源.txt"]
|
files_to_remove = ['去重.txt', "2.txt", "iptv.txt", "e.txt", "a0.txt", "a.txt", "a1.txt", "b.txt", "c.txt", "c1.txt", "c2.txt", "d.txt", "f.txt", "o1.txt", "o.txt", "酒店源.txt"]
|
||||||
for file in files_to_remove:
|
for file in files_to_remove:
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|||||||
Reference in New Issue
Block a user