Update 酒店源.py
This commit is contained in:
@@ -112,26 +112,36 @@ for url in urls:
|
||||
print(url)
|
||||
# 遍历网址列表,获取JSON文件并解析
|
||||
for url in valid_urls:
|
||||
# 遍历 valid_urls 列表中的每个 URL
|
||||
try:
|
||||
# 发送GET请求获取JSON文件,设置超时时间为0.5秒
|
||||
# 发送 GET 请求获取 JSON 文件,设置超时时间为 3 秒(你代码中此处 timeout 的值为 3,不是你注释里的 0.5 秒)
|
||||
json_url = f"{url}"
|
||||
response = requests.get(json_url, timeout=3)################################
|
||||
response = requests.get(json_url, timeout=3)
|
||||
json_data = response.content.decode('utf-8')
|
||||
# 将获取到的响应内容解码为 UTF-8 格式的字符串
|
||||
try:
|
||||
# 按行分割数据
|
||||
lines = json_data.split('\n')
|
||||
for line in lines:
|
||||
if 'hls' in line and ('udp' not in line or 'rtp' not in line): #行中需包含m3u,但排除udp和trp
|
||||
# 检查行中需包含'hls',但排除'udp'和'trp'
|
||||
if 'hls' in line and ('udp' not in line or 'rtp' not in line):
|
||||
line = line.strip()
|
||||
if line:
|
||||
# 如果行不为空,进行分割操作
|
||||
name, channel_url = line.split(',')
|
||||
urls = channel_url.split('/', 5)
|
||||
url_data = json_url.split('/', 5)
|
||||
if len(urls) >= 3:
|
||||
if len(urls) >= 5:
|
||||
# 构建新的 URL
|
||||
urld = (f"{urls[0]}//{url_data[1]}/{urls[2]}/{urls[3]}/{urls[4]}")
|
||||
else:
|
||||
urld = (f"{urls}")
|
||||
print(f"{name},{urld}")
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
|
||||
if name and urld:
|
||||
name = name.replace("高清电影", "影迷电影")
|
||||
name = name.replace("中央", "CCTV")
|
||||
|
||||
Reference in New Issue
Block a user