Skip to content
Open

1 #34

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
70f3974
Add files via upload
xuy132 Jul 18, 2024
24b8b54
Add files via upload
xuy132 Jul 18, 2024
39f48d5
:tada: AutoUpdate 20240718
actions-user Jul 18, 2024
8bf7e5c
Archive file with timestamp
actions-user Jul 18, 2024
6747f30
Update main.py
xuy132 Jul 18, 2024
379c861
Update main.py
xuy132 Jul 18, 2024
2c569cf
Update main.py
xuy132 Jul 18, 2024
55916a1
Update main.py
xuy132 Jul 18, 2024
86d9911
Update main.py
xuy132 Jul 18, 2024
1105bc8
Update main.py
xuy132 Jul 18, 2024
59ce870
:tada: AutoUpdate 20240718
actions-user Jul 18, 2024
dd35d83
Archive file with timestamp
actions-user Jul 18, 2024
b801094
Update main.py
xuy132 Jul 18, 2024
f9534b7
Update main.py
xuy132 Jul 18, 2024
e0b0d9c
:tada: AutoUpdate 20240718
actions-user Jul 18, 2024
35e6c63
Archive file with timestamp
actions-user Jul 18, 2024
f4af100
Update main.py
xuy132 Jul 18, 2024
7d07d13
Update main.py
xuy132 Jul 18, 2024
1593a4b
Update main.py
xuy132 Jul 18, 2024
050450a
Update main.py
xuy132 Jul 18, 2024
dd7f47e
Update main.py
xuy132 Jul 18, 2024
001f727
Update main.py
xuy132 Jul 18, 2024
6df3ab2
Update main.py
xuy132 Jul 18, 2024
9c19ec1
Update main.py
xuy132 Jul 18, 2024
b0c61c2
Update main.py
xuy132 Jul 18, 2024
edccadf
Update main.py
xuy132 Jul 18, 2024
219f17c
Update main.py
xuy132 Jul 18, 2024
f02d11f
Update main.py
xuy132 Jul 18, 2024
a145244
Update main.py
xuy132 Jul 18, 2024
771aae8
Update main.py
xuy132 Jul 18, 2024
63ae495
Update main.py
xuy132 Jul 18, 2024
c0012c5
Update main.py
xuy132 Jul 18, 2024
13a13b8
:tada: AutoUpdate 20240718
actions-user Jul 18, 2024
1b176c7
Archive file with timestamp
actions-user Jul 18, 2024
727baee
Update main.py
xuy132 Jul 18, 2024
8699938
Update main.py
xuy132 Jul 18, 2024
e7fef86
Update main.py
xuy132 Jul 18, 2024
8496867
Update main.py
xuy132 Jul 18, 2024
e3622c5
Update main.py
xuy132 Jul 18, 2024
0f0d8ef
Update main.py
xuy132 Jul 18, 2024
fa58b95
Update main.py
xuy132 Jul 18, 2024
76400b5
Update main.py
xuy132 Jul 18, 2024
e005e2b
:tada: AutoUpdate 20240718
actions-user Jul 18, 2024
a883d20
Archive file with timestamp
actions-user Jul 18, 2024
f3d196f
Update README.md
xuy132 Jul 18, 2024
6ecfefe
:tada: AutoUpdate 20240719
actions-user Jul 19, 2024
19e9f49
Archive file with timestamp
actions-user Jul 19, 2024
d82e3ef
Update main.py
xuy132 Jul 19, 2024
2186ede
:tada: AutoUpdate 20240719
actions-user Jul 19, 2024
8079f96
Archive file with timestamp
actions-user Jul 19, 2024
c7779e4
Update main.py
xuy132 Jul 19, 2024
5cec4c3
:tada: AutoUpdate 20240719
actions-user Jul 19, 2024
4e1e09a
Archive file with timestamp
actions-user Jul 19, 2024
97f811c
Update main.py
xuy132 Jul 19, 2024
3247c7e
:tada: AutoUpdate 20240719
actions-user Jul 19, 2024
69f2f90
Archive file with timestamp
actions-user Jul 19, 2024
d03fdba
Update main.py
xuy132 Jul 19, 2024
8ff4c40
Update main.py
xuy132 Jul 19, 2024
0302a0f
:tada: AutoUpdate 20240719
actions-user Jul 19, 2024
bbc25bd
Archive file with timestamp
actions-user Jul 19, 2024
4fdc388
:tada: AutoUpdate 20240720
actions-user Jul 20, 2024
1144585
Archive file with timestamp
actions-user Jul 20, 2024
6ae1512
:tada: AutoUpdate 20240721
actions-user Jul 21, 2024
813fcac
Archive file with timestamp
actions-user Jul 21, 2024
9087b30
Add files via upload
xuy132 Jul 22, 2024
2d5511c
Add files via upload
xuy132 Jul 22, 2024
a63d2a4
Add files via upload
xuy132 Jul 22, 2024
6b9aa31
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
879fd03
Archive file with timestamp
actions-user Jul 22, 2024
70565e2
Update main.py
xuy132 Jul 22, 2024
323187a
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
07621d6
Archive file with timestamp
actions-user Jul 22, 2024
873d3c9
Update main.py
xuy132 Jul 22, 2024
0d813a0
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
91c4aab
Archive file with timestamp
actions-user Jul 22, 2024
dea4238
Update main.py
xuy132 Jul 22, 2024
bee4ea8
Update main.py
xuy132 Jul 22, 2024
13f21ba
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
66a5e94
Archive file with timestamp
actions-user Jul 22, 2024
88ce6ad
Update main.py
xuy132 Jul 22, 2024
c26b271
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
0c70f45
Archive file with timestamp
actions-user Jul 22, 2024
e039eee
Update main.py
xuy132 Jul 22, 2024
fa65b5b
Add files via upload
xuy132 Jul 22, 2024
f7ca5e7
Update main.py
xuy132 Jul 22, 2024
abf94a1
Update main.py
xuy132 Jul 22, 2024
83dc64e
Update main.py
xuy132 Jul 22, 2024
2f59472
Update main.py
xuy132 Jul 22, 2024
d864f6c
Update main.py
xuy132 Jul 22, 2024
4609d7b
Update main.py
xuy132 Jul 22, 2024
ec2f63e
Update main.py
xuy132 Jul 22, 2024
ee3a18e
:tada: AutoUpdate 20240722
actions-user Jul 22, 2024
f15c72c
Archive file with timestamp
actions-user Jul 22, 2024
7fcb6dc
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
d1552c3
Archive file with timestamp
actions-user Jul 23, 2024
e7fd8bc
Update main.py
xuy132 Jul 23, 2024
d03c2da
Update main.py
xuy132 Jul 23, 2024
0b15360
Update main.py
xuy132 Jul 23, 2024
5a593bd
Update main.py
xuy132 Jul 23, 2024
a659a97
Update main.py
xuy132 Jul 23, 2024
9c7345f
Update main.py
xuy132 Jul 23, 2024
8feaf88
Update main.py
xuy132 Jul 23, 2024
036f5c9
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
c494721
Archive file with timestamp
actions-user Jul 23, 2024
5ef10fa
Update main.py
xuy132 Jul 23, 2024
12d7322
Update main.py
xuy132 Jul 23, 2024
778318c
Update main.py
xuy132 Jul 23, 2024
6deff50
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
11ecd33
Archive file with timestamp
actions-user Jul 23, 2024
220be7f
Update main.py
xuy132 Jul 23, 2024
315d2f0
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
0ca1cb4
Archive file with timestamp
actions-user Jul 23, 2024
8a22413
Update main.py
xuy132 Jul 23, 2024
0c6c4a0
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
ea9cee5
Archive file with timestamp
actions-user Jul 23, 2024
0f58b1b
Update and rename 实景直播.txt to 直播中国.txt
xuy132 Jul 23, 2024
d14d94d
Update main.py
xuy132 Jul 23, 2024
bc8e532
:tada: AutoUpdate 20240723
actions-user Jul 23, 2024
dd7c3a5
Archive file with timestamp
actions-user Jul 23, 2024
69dbe39
Update 解说频道.txt
xuy132 Jul 23, 2024
850071a
:tada: AutoUpdate 20240724
actions-user Jul 24, 2024
b8ca626
Archive file with timestamp
actions-user Jul 24, 2024
5e90015
:tada: AutoUpdate 20240725
actions-user Jul 25, 2024
b2d6be6
Archive file with timestamp
actions-user Jul 25, 2024
09406bf
:tada: AutoUpdate 20240726
actions-user Jul 26, 2024
4071df8
Archive file with timestamp
actions-user Jul 26, 2024
96a8352
:tada: AutoUpdate 20240727
actions-user Jul 27, 2024
40b7bd0
Archive file with timestamp
actions-user Jul 27, 2024
ad2629b
:tada: AutoUpdate 20240728
actions-user Jul 28, 2024
9d80538
Archive file with timestamp
actions-user Jul 28, 2024
fa222ed
:tada: AutoUpdate 20240729
actions-user Jul 29, 2024
f2fffae
Archive file with timestamp
actions-user Jul 29, 2024
23ee6fe
:tada: AutoUpdate 20240730
actions-user Jul 30, 2024
2acca12
Archive file with timestamp
actions-user Jul 30, 2024
b64a1bf
:tada: AutoUpdate 20240731
actions-user Jul 31, 2024
0207543
Archive file with timestamp
actions-user Jul 31, 2024
e1a9b41
:tada: AutoUpdate 20240801
actions-user Aug 1, 2024
a334c18
Archive file with timestamp
actions-user Aug 1, 2024
2b4c8ba
:tada: AutoUpdate 20240802
actions-user Aug 2, 2024
b15957d
Archive file with timestamp
actions-user Aug 2, 2024
6b7b1d8
:tada: AutoUpdate 20240803
actions-user Aug 3, 2024
aa1e86b
Archive file with timestamp
actions-user Aug 3, 2024
b6d61b3
:tada: AutoUpdate 20240804
actions-user Aug 4, 2024
4d481a3
Archive file with timestamp
actions-user Aug 4, 2024
d9b03f9
:tada: AutoUpdate 20240805
actions-user Aug 5, 2024
0861314
Archive file with timestamp
actions-user Aug 5, 2024
efbd7d7
:tada: AutoUpdate 20240806
actions-user Aug 6, 2024
d471f48
Archive file with timestamp
actions-user Aug 6, 2024
930d1a7
:tada: AutoUpdate 20240807
actions-user Aug 7, 2024
45276e3
Archive file with timestamp
actions-user Aug 7, 2024
3f0c927
:tada: AutoUpdate 20240808
actions-user Aug 8, 2024
6160d9e
Archive file with timestamp
actions-user Aug 8, 2024
2de9aa4
:tada: AutoUpdate 20240809
actions-user Aug 9, 2024
092dcb4
Archive file with timestamp
actions-user Aug 9, 2024
f55f2b9
:tada: AutoUpdate 20240810
actions-user Aug 10, 2024
ea9d343
Archive file with timestamp
actions-user Aug 10, 2024
d5e2bbc
:tada: AutoUpdate 20240811
actions-user Aug 11, 2024
c1e77e3
Archive file with timestamp
actions-user Aug 11, 2024
c57e693
:tada: AutoUpdate 20240812
actions-user Aug 12, 2024
a2bba06
Archive file with timestamp
actions-user Aug 12, 2024
648b62d
:tada: AutoUpdate 20240813
actions-user Aug 13, 2024
695d72a
Archive file with timestamp
actions-user Aug 13, 2024
8378c65
:tada: AutoUpdate 20240814
actions-user Aug 14, 2024
38462af
Archive file with timestamp
actions-user Aug 14, 2024
3b97e6b
:tada: AutoUpdate 20240815
actions-user Aug 15, 2024
508fc05
Archive file with timestamp
actions-user Aug 15, 2024
e6caf4b
:tada: AutoUpdate 20240816
actions-user Aug 16, 2024
4c5a97b
Archive file with timestamp
actions-user Aug 16, 2024
dfc2246
:tada: AutoUpdate 20240817
actions-user Aug 17, 2024
7243d29
Archive file with timestamp
actions-user Aug 17, 2024
0d21e5e
:tada: AutoUpdate 20240818
actions-user Aug 18, 2024
0d7dea3
Archive file with timestamp
actions-user Aug 18, 2024
9b9346b
:tada: AutoUpdate 20240819
actions-user Aug 19, 2024
ca4addd
Archive file with timestamp
actions-user Aug 19, 2024
beaddc8
:tada: AutoUpdate 20240820
actions-user Aug 20, 2024
9cdd712
Archive file with timestamp
actions-user Aug 20, 2024
54f68ff
:tada: AutoUpdate 20240821
actions-user Aug 21, 2024
2bbafb0
Archive file with timestamp
actions-user Aug 21, 2024
68340bd
:tada: AutoUpdate 20240822
actions-user Aug 22, 2024
58e1de0
Archive file with timestamp
actions-user Aug 22, 2024
26b2326
:tada: AutoUpdate 20240823
actions-user Aug 23, 2024
1979040
Archive file with timestamp
actions-user Aug 23, 2024
83fe4bc
:tada: AutoUpdate 20240824
actions-user Aug 24, 2024
986d52e
Archive file with timestamp
actions-user Aug 24, 2024
fe3c319
:tada: AutoUpdate 20240825
actions-user Aug 25, 2024
3316f68
Archive file with timestamp
actions-user Aug 25, 2024
0e5c639
:tada: AutoUpdate 20240826
actions-user Aug 26, 2024
8578019
Archive file with timestamp
actions-user Aug 26, 2024
0e9dd7c
:tada: AutoUpdate 20240827
actions-user Aug 27, 2024
eaf4ce8
Archive file with timestamp
actions-user Aug 27, 2024
65f3f75
:tada: AutoUpdate 20240828
actions-user Aug 28, 2024
40151a7
Archive file with timestamp
actions-user Aug 28, 2024
e81e69f
:tada: AutoUpdate 20240829
actions-user Aug 29, 2024
248f47e
Archive file with timestamp
actions-user Aug 29, 2024
00a5596
:tada: AutoUpdate 20240830
actions-user Aug 30, 2024
ac0fc90
Archive file with timestamp
actions-user Aug 30, 2024
94770e5
:tada: AutoUpdate 20240831
actions-user Aug 31, 2024
5103881
Archive file with timestamp
actions-user Aug 31, 2024
a7abeb3
:tada: AutoUpdate 20240901
actions-user Sep 1, 2024
3bb75e6
Archive file with timestamp
actions-user Sep 1, 2024
4184191
:tada: AutoUpdate 20240902
actions-user Sep 2, 2024
50b90b2
Archive file with timestamp
actions-user Sep 2, 2024
be9095d
:tada: AutoUpdate 20240903
actions-user Sep 3, 2024
3517516
Archive file with timestamp
actions-user Sep 3, 2024
4a158aa
:tada: AutoUpdate 20240904
actions-user Sep 4, 2024
5e17cb1
Archive file with timestamp
actions-user Sep 4, 2024
4f4bf6c
:tada: AutoUpdate 20240905
actions-user Sep 5, 2024
a32dbb4
Archive file with timestamp
actions-user Sep 5, 2024
d10aee5
:tada: AutoUpdate 20240906
actions-user Sep 6, 2024
24b7b9f
Archive file with timestamp
actions-user Sep 6, 2024
8481754
:tada: AutoUpdate 20240907
actions-user Sep 7, 2024
df61ff4
Archive file with timestamp
actions-user Sep 7, 2024
0b7dbd9
:tada: AutoUpdate 20240908
actions-user Sep 8, 2024
9caf232
Archive file with timestamp
actions-user Sep 8, 2024
7a5fbc6
:tada: AutoUpdate 20240909
actions-user Sep 9, 2024
1d58015
Archive file with timestamp
actions-user Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

### **直播源(txt):**
```
https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.txt
https://raw.githubusercontent.com/xuy132/collect-tv-txt/main/merged_output.txt
```
直播源(txt)短链:
```
http://gg.gg/tv-live-txt
```
镜像源(txt):
```
https://ghproxy.net/https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.txt
https://ghproxy.net/https://raw.githubusercontent.com/xuy132/collect-tv-txt/main/merged_output.txt
```
镜像源(txt)短链:
```
http://gg.gg/tv-live-txt-mirr
```
### **直播源(m3u):**
```
https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.m3u
https://raw.githubusercontent.com/xuy132/collect-tv-txt/main/merged_output.m3u
```
直播源(m3u)短链:
```
Expand All @@ -37,14 +37,14 @@ http://gg.gg/tv-live-m3u

| 类 别 | 直播源 | ShortLink |
|-------|------------------------------------------------|------------|
| (txt) | https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.txt | http://gg.gg/tv-live-txt |
| (m3u) | https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.m3u | http://gg.gg/tv-live-m3u |
| (txt) | https://raw.githubusercontent.com/xuy132/collect-tv-txt/main/merged_output.txt | http://gg.gg/tv-live-txt |
| (m3u) | https://raw.githubusercontent.com/xuy132/collect-tv-txt/main/merged_output.m3u | http://gg.gg/tv-live-m3u |


如果有其他定期更新稳定的源也可以留言,有时间一起加在收集列表里。

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=kimwang1978/collect-tv-txt&type=Date)](https://star-history.com/#kimwang1978/collect-tv-txt&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=xuy132/collect-tv-txt&type=Date)](https://star-history.com/#xuy132/collect-tv-txt&Date)


245 changes: 245 additions & 0 deletions blacklist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
import urllib.request
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
from datetime import datetime
import os
from urllib.parse import urlparse


timestart = datetime.now()

# 读取文件内容
def read_txt_file(file_path):
skip_strings = ['#genre#'] # 定义需要跳过的字符串数组['#', '@', '#genre#']
required_strings = ['://'] # 定义需要包含的字符串数组['必需字符1', '必需字符2']

with open(file_path, 'r', encoding='utf-8') as file:
lines = [
line for line in file
if not any(skip_str in line for skip_str in skip_strings) and all(req_str in line for req_str in required_strings)
]
return lines

# 检测URL是否可访问并记录响应时间
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
}
def check_url(url, timeout=8):
try:
if "://" in url:
start_time = time.time()
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req, timeout=timeout) as response:
elapsed_time = (time.time() - start_time) * 1000 # 转换为毫秒
if response.status == 200:
return elapsed_time, True
except Exception as e:
print(f"Error checking {url}: {e}")
return None, False

# 处理单行文本并检测URL
def process_line(line):
if "#genre#" in line or "://" not in line :
return None, None # 跳过包含“#genre#”的行
parts = line.split(',')
if len(parts) == 2:
name, url = parts
elapsed_time, is_valid = check_url(url.strip())
if is_valid:
return elapsed_time, line.strip()
else:
return None, line.strip()
return None, None

# 多线程处理文本并检测URL
def process_urls_multithreaded(lines, max_workers=18):
blacklist = []
successlist = []

with ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = {executor.submit(process_line, line): line for line in lines}
for future in as_completed(futures):
elapsed_time, result = future.result()
if result:
if elapsed_time is not None:
successlist.append(f"{elapsed_time:.2f}ms,{result}")
else:
blacklist.append(result)
return successlist, blacklist

# 写入文件
def write_list(file_path, data_list):
with open(file_path, 'w', encoding='utf-8') as file:
for item in data_list:
file.write(item + '\n')

# 增加外部url到检测清单,同时支持检测m3u格式url
# urls里所有的源都读到这里。
urls_all_lines = []

def get_url_file_extension(url):
# 解析URL
parsed_url = urlparse(url)
# 获取路径部分
path = parsed_url.path
# 提取文件扩展名
extension = os.path.splitext(path)[1]
return extension

def convert_m3u_to_txt(m3u_content):
# 分行处理
lines = m3u_content.split('\n')

# 用于存储结果的列表
txt_lines = []

# 临时变量用于存储频道名称
channel_name = ""

for line in lines:
# 过滤掉 #EXTM3U 开头的行
if line.startswith("#EXTM3U"):
continue
# 处理 #EXTINF 开头的行
if line.startswith("#EXTINF"):
# 获取频道名称(假设频道名称在引号后)
channel_name = line.split(',')[-1].strip()
# 处理 URL 行
elif line.startswith("http"):
txt_lines.append(f"{channel_name},{line.strip()}")

# 将结果合并成一个字符串,以换行符分隔
return '\n'.join(txt_lines)

def process_url(url):
try:
# 打开URL并读取内容
with urllib.request.urlopen(url) as response:
# 以二进制方式读取数据
data = response.read()
# 将二进制数据解码为字符串
text = data.decode('utf-8')
if get_url_file_extension(url)==".m3u" or get_url_file_extension(url)==".m3u8":
urls_all_lines.append(convert_m3u_to_txt(text))
elif get_url_file_extension(url)==".txt":
lines = text.split('\n')
for line in lines:
if "#genre#" not in line and "," in line and "://" in line:
#channel_name=line.split(',')[0].strip()
#channel_address=line.split(',')[1].strip()
urls_all_lines.append(line.strip())

except Exception as e:
print(f"处理URL时发生错误:{e}")


if __name__ == "__main__":
# 定义要访问的多个URL
urls = [
'https://raw.githubusercontent.com/YanG-1989/m3u/main/Gather.m3u',
'https://raw.githubusercontent.com/iptv-org/iptv/master/streams/cn.m3u',
'https://gitlab.com/p2v5/wangtv/-/raw/main/wang-tvlive.txt',
'https://raw.githubusercontent.com/kimwang1978/tvbox/main/%E5%A4%A9%E5%A4%A9%E5%BC%80%E5%BF%83/lives/%E2%91%AD%E5%BC%80%E5%BF%83%E7%BA%BF%E8%B7%AF.txt',
'https://raw.githubusercontent.com/mlvjfchen/TV/main/iptv_list.txt'
]
for url in urls:
print(f"处理URL: {url}")
process_url(url) #读取上面url清单中直播源存入urls_all_lines

# 获取当前脚本所在的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上一层目录
parent_dir = os.path.dirname(current_dir)

input_file1 = os.path.join(parent_dir, 'merged_output.txt') # 输入文件路径1
input_file2 = os.path.join(current_dir, 'blacklist_auto.txt') # 输入文件路径2
success_file = os.path.join(current_dir, 'whitelist_auto.txt') # 成功清单文件路径
success_file_tv = os.path.join(current_dir, 'whitelist_auto_tv.txt') # 成功清单文件路径(另存一份直接引用源)
blacklist_file = os.path.join(current_dir, 'blacklist_auto.txt') # 黑名单文件路径

# 读取输入文件内容
lines1 = read_txt_file(input_file1)
lines2 = read_txt_file(input_file2)
lines=list(set(urls_all_lines + lines1 + lines2))
# 计算合并后合计个数
urls_hj = len(lines)

# 处理URL并生成成功清单和黑名单
successlist, blacklist = process_urls_multithreaded(lines)

# 给successlist, blacklist排序
# 定义排序函数
def successlist_sort_key(item):
time_str = item.split(',')[0].replace('ms', '')
return float(time_str)

successlist=sorted(set(successlist), key=successlist_sort_key)
blacklist=sorted(set(blacklist))

# 计算check后ok和ng个数
urls_ok = len(successlist)
urls_ng = len(blacklist)

# 把successlist整理一下,生成一个可以直接引用的源,方便用zyplayer手动check
def remove_prefix_from_lines(lines):
result = []
for line in lines:
if "#genre#" not in line and "," in line and "://" in line:
parts = line.split(",")
result.append(",".join(parts[1:]))
return result


# 加时间戳等
version=datetime.now().strftime("%Y%m%d-%H-%M-%S")+",url"
successlist_tv = ["更新时间,#genre#"] +[version] + ['\n'] +\
["whitelist,#genre#"] + remove_prefix_from_lines(successlist)
successlist = ["更新时间,#genre#"] +[version] + ['\n'] +\
["RespoTime,whitelist,#genre#"] + successlist
blacklist = ["更新时间,#genre#"] +[version] + ['\n'] +\
["blacklist,#genre#"] + blacklist

# 写入成功清单文件
write_list(success_file, successlist)
write_list(success_file_tv, successlist_tv)

# 写入黑名单文件
write_list(blacklist_file, blacklist)

print(f"成功清单文件已生成: {success_file}")
print(f"成功清单文件已生成(tv): {success_file_tv}")
print(f"黑名单文件已生成: {blacklist_file}")

# 写入history
timenow=datetime.now().strftime("%Y%m%d_%H_%M_%S")
history_success_file = f'history/blacklist/{timenow}_whitelist_auto.txt'
history_blacklist_file = f'history/blacklist/{timenow}_blacklist_auto.txt'
write_list(history_success_file, successlist)
write_list(history_blacklist_file, successlist)
print(f"history成功清单文件已生成: {history_success_file}")
print(f"history黑名单文件已生成: {history_blacklist_file}")

# 执行的代码
timeend = datetime.now()

# 计算时间差
elapsed_time = timeend - timestart
total_seconds = elapsed_time.total_seconds()

# 转换为分钟和秒
minutes = int(total_seconds // 60)
seconds = int(total_seconds % 60)

# 格式化开始和结束时间
timestart_str = timestart.strftime("%Y%m%d_%H_%M_%S")
timeend_str = timeend.strftime("%Y%m%d_%H_%M_%S")

print(f"开始时间: {timestart_str}")
print(f"结束时间: {timeend_str}")
print(f"执行时间: {minutes} 分 {seconds} 秒")
print(f"urls_hj: {urls_hj} ")
print(f" urls_ok: {urls_ok} ")
print(f" urls_ng: {urls_ng} ")



Loading