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