Merge pull request from Guovin/dev

Dev
This commit is contained in:
Govin 2024-11-14 14:12:55 +08:00 committed by GitHub
commit ec23752af7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 1451 additions and 81 deletions

@ -21,7 +21,11 @@
</div>
<br>
<div>
🏠广东频道: 广东珠江, 广东体育, 广东新闻, 广东民生, 广东卫视, 大湾区卫视, 广州综合, 广州影视, 广州竞赛, 江门综合, 江门侨乡生活, 佛山综合, 深圳卫视, 汕头综合, 汕头经济, 汕头文旅, 茂名综合, 茂名公共
☘️广东频道: 广东珠江, 广东体育, 广东新闻, 广东民生, 广东卫视, 大湾区卫视, 广州综合, 广州影视, 广州竞赛, 江门综合, 江门侨乡生活, 佛山综合, 深圳卫视, 汕头综合, 汕头经济, 汕头文旅, 茂名综合, 茂名公共
</div>
<br>
<div>
☘️各省份地方台
</div>
<br>
<div>
@ -152,23 +156,29 @@ pipenv run ui
建议都试用一次,选择自己合适的版本
1. 拉取镜像:
- driver
```bash
docker pull guovern/tv-driver:latest
```
- requests
```bash
docker pull guovern/tv-requests:latest
```
2. 运行容器:
- driver
```bash
docker run -d -p 8000:8000 guovern/tv-driver
```
- requests
```bash
docker run -d -p 8000:8000 guovern/tv-requests
```
@ -176,13 +186,16 @@ docker run -d -p 8000:8000 guovern/tv-requests
卷挂载参数(可选):
实现宿主机文件与容器文件同步,修改模板、配置、获取更新结果文件可直接在宿主机文件夹下操作
以宿主机路径/etc/docker为例
以宿主机路径/etc/docker 为例:
- driver
```bash
docker run -v /etc/docker/config:/tv-driver/config -v /etc/docker/output:/tv-driver/output -d -p 8000:8000 guovern/tv-driver
```
- requests
```bash
docker run -v /etc/docker/config:/tv-requests/config -v /etc/docker/output:/tv-requests/output -d -p 8000:8000 guovern/tv-requests
```

@ -21,7 +21,11 @@
</div>
<br>
<div>
🏠Guangdong Channel: 广东珠江, 广东体育, 广东新闻, 广东民生, 广东卫视, 大湾区卫视, 广州综合, 广州影视, 广州竞赛, 江门综合, 江门侨乡生活, 佛山综合, 深圳卫视, 汕头综合, 汕头经济, 汕头文旅, 茂名综合, 茂名公共
Guangdong Channel: 广东珠江, 广东体育, 广东新闻, 广东民生, 广东卫视, 大湾区卫视, 广州综合, 广州影视, 广州竞赛, 江门综合, 江门侨乡生活, 佛山综合, 深圳卫视, 汕头综合, 汕头经济, 汕头文旅, 茂名综合, 茂名公共
</div>
<br>
<div>
Local channels in each province
</div>
<br>
<div>
@ -152,23 +156,29 @@ pipenv run ui
It's recommended to try each one and choose the version that suits you
1. Pull the image:
- driver
```bash
docker pull guovern/tv-driver:latest
```
- requests
```bash
docker pull guovern/tv-requests:latest
```
2. Run the container:
- driver
```bash
docker run -d -p 8000:8000 guovern/tv-driver
```
- requests
```bash
docker run -d -p 8000:8000 guovern/tv-requests
```
@ -179,14 +189,16 @@ This allows synchronization of files between the host machine and the container.
Taking the host path /etc/docker as an example:
- driver
```bash
docker run -v /etc/docker/config:/tv-driver/config -v /etc/docker/output:/tv-driver/output -d -p 8000:8000 guovern/tv-driver
```
- requests
```bash
docker run -v /etc/docker/config:/tv-requests/config -v /etc/docker/output:/tv-requests/output -d -p 8000:8000 guovern/tv-requests
````
```
3. Update results:
- API address: ip:8000

@ -5,8 +5,8 @@ open_use_old_result = True
source_file = config/demo.txt
final_file = output/result.txt
open_online_search = False
online_search_page_num = 3
urls_limit = 30
online_search_page_num = 1
urls_limit = 10
open_keep_all = False
open_sort = True
sort_timeout = 10
@ -18,9 +18,9 @@ resolution_weight = 0.5
recent_days = 30
ipv_type = 全部
ipv_type_prefer = 自动
ipv4_num = 15
ipv6_num = 15
domain_blacklist = epg.pw,skype.serv00.net,iptv.yjxfz.com,live-hls-web-ajb.getaj.net,live.goodiptv.club,hc73k3dhwo5gfkt.wcetv.com,stream1.freetv.fun
ipv4_num = 5
ipv6_num = 5
domain_blacklist = epg.pw,skype.serv00.net,iptv.yjxfz.com,live-hls-web-ajb.getaj.net,live.goodiptv.club,hc73k3dhwo5gfkt.wcetv.com,stream1.freetv.fun,zw9999.cnstream.top
open_m3u_result = True
url_keywords_blacklist =
open_subscribe = True
@ -40,9 +40,9 @@ hotel_page_num = 1
open_update_time = True
request_timeout = 10
origin_type_prefer = hotel,multicast,subscribe,online_search
hotel_num = 10
multicast_num = 10
subscribe_num = 10
hotel_num = 4
multicast_num = 3
subscribe_num = 3
online_search_num = 0
open_url_info = True
open_empty_category = True
open_empty_category = False

File diff suppressed because it is too large Load Diff

@ -8,11 +8,11 @@
| source_file | config/demo.txt | 模板文件路径 |
| final_file | output/result.txt | 生成结果文件路径 |
| open_online_search | False | 开启关键字搜索源功能 |
| online_search_page_num | 3 | 关键字搜索频道获取分页数量 |
| urls_limit | 15 | 单个频道接口数量 |
| online_search_page_num | 1 | 关键字搜索频道获取分页数量 |
| urls_limit | 10 | 单个频道接口数量 |
| open_keep_all | False | 保留所有检索结果,会保留非模板频道名称的结果,推荐手动维护时开启 |
| open_sort | True | 开启排序功能(响应速度、日期、分辨率) |
| sort_timeout | 5 | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 |
| sort_timeout | 10 | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 |
| open_ffmpeg | True | 开启使用 FFmpeg 进行测速,获取更准确的速度与分辨率信息,需要提前手动安装 |
| open_m3u_result | True | 开启转换生成 m3u 文件类型结果链接,支持显示频道图标 |
| open_filter_resolution | True | 开启分辨率过滤低于最小分辨率min_resolution的接口将会被过滤 |
@ -20,10 +20,10 @@
| response_time_weight | 0.5 | 响应时间权重值(所有权重值总和应为 1 |
| resolution_weight | 0.5 | 分辨率权重值 (所有权重值总和应为 1 |
| recent_days | 30 | 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 |
| ipv_type | ipv4 | 生成结果中接口的协议类型可选值ipv4、ipv6、全部 |
| ipv_type_prefer | IPv4 | 接口协议类型偏好优先将该类型的接口排在结果前面可选值IPv4、IPv6、自动 |
| ipv4_num | 15 | 结果中偏好的 IPv4 接口数量 |
| ipv6_num | 15 | 结果中偏好的 IPv6 接口数量 |
| ipv_type | 全部 | 生成结果中接口的协议类型可选值ipv4、ipv6、全部、all |
| ipv_type_prefer | 自动 | 接口协议类型偏好优先将该类型的接口排在结果前面可选值IPv4、IPv6、自动、auto |
| ipv4_num | 5 | 结果中偏好的 IPv4 接口数量 |
| ipv6_num | 5 | 结果中偏好的 IPv6 接口数量 |
| domain_blacklist | epg.pw | 接口域名黑名单,用于过滤低质量含广告类域名的接口 |
| url_keywords_blacklist | | 接口关键字黑名单,用于过滤含特定字符的接口 |
| open_subscribe | False | 开启订阅源功能 |
@ -32,17 +32,17 @@
| open_multicast_foodie | True | 开启 Foodie 组播源工作模式 |
| open_multicast_fofa | True | 开启 FOFA 组播源工作模式 |
| multicast_region_list | 全部 | 组播源地区列表,[更多地区](../updates/multicast/multicast_map.json)"全部"表示所有地区 |
| multicast_page_num | 3 | 组播地区获取分页数量 |
| multicast_page_num | 1 | 组播地区获取分页数量 |
| open_hotel | True | 开启酒店源功能,关闭后所有酒店源工作模式都将关闭 |
| open_hotel_foodie | False | 开启 Foodie 酒店源工作模式 |
| open_hotel_foodie | True | 开启 Foodie 酒店源工作模式 |
| open_hotel_fofa | True | 开启 FOFA、ZoomEye 酒店源工作模式 |
| hotel_region_list | 全部 | 酒店源地区列表,[更多地区](../updates/fofa/fofa_map.py)"全部"表示所有地区 |
| hotel_page_num | 3 | 酒店地区获取分页数量 |
| hotel_page_num | 1 | 酒店地区获取分页数量 |
| request_timeout | 10 | 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 |
| origin_type_prefer | hotel,multicast,subscribe,online_search | 结果偏好的接口来源结果优先按该顺序进行排序hotel酒店源multicast组播源subscribe订阅源online_search关键字搜索 |
| hotel_num | 10 | 结果中偏好的酒店源接口数量 |
| multicast_num | 10 | 结果中偏好的组播源接口数量 |
| subscribe_num | 10 | 结果中偏好的订阅源接口数量 |
| online_search_num | 10 | 结果中偏好的关键字搜索接口数量 |
| hotel_num | 4 | 结果中偏好的酒店源接口数量 |
| multicast_num | 3 | 结果中偏好的组播源接口数量 |
| subscribe_num | 3 | 结果中偏好的订阅源接口数量 |
| online_search_num | 0 | 结果中偏好的关键字搜索接口数量 |
| open_url_info | True | 开启显示接口说明信息,用于控制是否显示分辨率、接口协议类型等信息,为$符号后的内容,播放软件使用该信息对接口进行描述 |
| open_empty_category | True | 开启无结果频道分类,自动归类至底部 |
| open_empty_category | False | 开启无结果频道分类,自动归类至底部 |

@ -8,11 +8,11 @@
| source_file | config/demo.txt | Template file path |
| final_file | output/result.txt | Generated result file path |
| open_online_search | False | Enable keyword search source feature |
| online_search_page_num | 3 | Page retrieval quantity for keyword search channels |
| urls_limit | 15 | Number of interfaces per channel |
| online_search_page_num | 1 | Page retrieval quantity for keyword search channels |
| urls_limit | 10 | Number of interfaces per channel |
| open_keep_all | False | Retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining |
| open_sort | True | Enable the sorting function (response speed, date, resolution) |
| sort_timeout | 5 | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. |
| sort_timeout | 10 | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. |
| open_ffmpeg | True | Enable speed testing using FFmpeg to obtain more accurate speed and resolution information. Manual installation is required in advance. |
| open_m3u_result | True | Enable the conversion to generate m3u file type result links, supporting the display of channel icons |
| open_filter_resolution | True | Enable resolution filtering, interfaces with resolution lower than the minimum resolution (min_resolution) will be filtered |
@ -20,29 +20,29 @@
| response_time_weight | 0.5 | Response time weight value (the sum of all weight values should be 1) |
| resolution_weight | 0.5 | Resolution weight value (the sum of all weight values should be 1) |
| recent_days | 30 | Retrieve interfaces updated within a recent time range (in days), reducing appropriately can avoid matching issues |
| ipv_type | ipv4 | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all |
| ipv_type_prefer | IPv4 | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto |
| ipv4_num | 15 | The preferred number of IPv4 interfaces in the result |
| ipv6_num | 15 | The preferred number of IPv6 interfaces in the result |
| domain_blacklist | epg.pw | Interface domain blacklist, used to filter out interfaces with low-quality, ad-inclusive domains |
| ipv_type | all | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all |
| ipv_type_prefer | auto | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto |
| ipv4_num | 5 | The preferred number of IPv4 interfaces in the result |
| ipv6_num | 5 | The preferred number of IPv6 interfaces in the result |
| domain_blacklist | | Interface domain blacklist, used to filter out interfaces with low-quality, ad-inclusive domains |
| url_keywords_blacklist | | Interface keyword blacklist, used to filter out interfaces containing specific characters |
| open_subscribe | False | Enable subscription source feature |
| open_subscribe | True | Enable subscription source feature |
| subscribe_urls | | Subscription source, please enter the subscription link (supports txt and m3u links), multiple links should be separated by commas |
| open_multicast | True | Enable the multicast source function, after disabling it all multicast sources will stop working |
| open_multicast_foodie | True | Enable Foodie multicast source work mode |
| open_multicast_fofa | True | Enable FOFA multicast source work mode |
| multicast_region_list | all | Multicast source region list, [more regions](../updates/multicast/multicast_map.json, all means all regions) |
| multicast_page_num | 3 | Number of pages to retrieve for multicast regions |
| multicast_page_num | 1 | Number of pages to retrieve for multicast regions |
| open_hotel | True | Enable the hotel source function, after closing it all hotel source working modes will be disabled |
| open_hotel_foodie | False | Enable Foodie hotel source work mode |
| open_hotel_foodie | True | Enable Foodie hotel source work mode |
| open_hotel_fofa | True | Enable FOFA、ZoomEye hotel source work mode |
| hotel_region_list | all | List of hotel source regions, [more regions](../updates/fofa/fofa_map.py), 'all' indicates all regions |
| hotel_page_num | 3 | Number of pages to retrieve for hotel regions |
| hotel_page_num | 1 | Number of pages to retrieve for hotel regions |
| request_timeout | 10 | Query request timeout duration, in seconds (s), used to control the timeout and retry duration for querying interface text links. Adjusting this value can optimize update time. |
| origin_type_prefer | hotel, multicast, subscribe, online_search | Result preference for the source of the interface, results are prioritized in this order: hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search |
| hotel_num | 10 | The number of preferred hotel source interfaces in the results |
| multicast_num | 10 | The number of preferred multicast source interfaces in the results |
| subscribe_num | 10 | The number of preferred subscribe source interfaces in the results |
| online_search_num | 10 | The number of preferred keyword search interfaces in the results |
| hotel_num | 4 | The number of preferred hotel source interfaces in the results |
| multicast_num | 3 | The number of preferred multicast source interfaces in the results |
| subscribe_num | 3 | The number of preferred subscribe source interfaces in the results |
| online_search_num | 0 | The number of preferred keyword search interfaces in the results |
| open_url_info | True | Enable display of API description information, used to control whether to show resolution, API protocol type, etc., the content after the $ symbol, playback software uses this information to describe the API |
| open_empty_category | True | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom |
| open_empty_category | False | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom |

Binary file not shown.

@ -7,6 +7,7 @@ from utils.tools import (
add_url_info,
remove_cache_info,
resource_path,
write_content_into_txt,
)
from utils.speed import (
sort_urls_by_speed_and_resolution,
@ -145,6 +146,8 @@ def format_channel_name(name):
return name
cc = OpenCC("t2s")
name = cc.convert(name)
for region in constants.region_list:
name = name.replace(f"{region}", "")
name = re.sub(constants.sub_pattern, "", name)
for old, new in constants.replace_dict.items():
name = name.replace(old, new)
@ -167,11 +170,7 @@ def get_channel_results_by_name(name, data):
Get channel results from data by name
"""
format_name = format_channel_name(name)
cc = OpenCC("s2t")
name_s2t = cc.convert(format_name)
result1 = data.get(format_name, [])
result2 = data.get(name_s2t, [])
results = list(dict.fromkeys(result1 + result2))
results = data.get(format_name, [])
return results
@ -408,32 +407,6 @@ def get_results_from_multicast_soup_requests(soup, hotel=False):
return results
def update_channel_urls_txt(cate, name, urls, callback=None):
"""
Update the category and channel urls to the final file
"""
genre_line = cate + ",#genre#\n"
filename = "output/result_new.txt"
if not os.path.exists(filename):
open(filename, "w").close()
with open(filename, "r", encoding="utf-8") as f:
content = f.read()
with open(filename, "a", encoding="utf-8") as f:
if genre_line not in content:
f.write(genre_line)
if urls:
for url in urls:
if url is not None:
f.write(f"{name},{url}\n")
if callback:
callback()
else:
f.write(f"{name},url\n")
def get_channel_url(text):
"""
Get the url from text
@ -727,16 +700,19 @@ def write_channel_to_file(data, ipv6=False, callback=None):
"""
Write channel to file
"""
path = "output/result_new.txt"
if config.open_update_time:
now = datetime.datetime.now()
if os.environ.get("GITHUB_ACTIONS"):
now += datetime.timedelta(hours=8)
update_time = now.strftime("%Y-%m-%d %H:%M:%S")
update_channel_urls_txt("更新时间", f"{update_time}", ["url"])
write_content_into_txt(f"更新时间,#genre#", path, newline=False)
write_content_into_txt(f"{update_time},url", path)
no_result_name = []
open_empty_category = config.open_empty_category
for cate, channel_obj in data.items():
print(f"\n{cate}:", end=" ")
write_content_into_txt(f"{cate},#genre#", path)
channel_obj_keys = channel_obj.keys()
names_len = len(list(channel_obj_keys))
for i, name in enumerate(channel_obj_keys):
@ -748,14 +724,17 @@ def write_channel_to_file(data, ipv6=False, callback=None):
if open_empty_category:
no_result_name.append(name)
continue
update_channel_urls_txt(cate, name, channel_urls, callback=callback)
for url in channel_urls:
write_content_into_txt(f"{name},{url}", path, callback=callback)
print()
write_content_into_txt("", path)
if open_empty_category and no_result_name:
print("\n🈳 No result channel name:")
write_content_into_txt("🈳无结果频道,#genre#", path)
for i, name in enumerate(no_result_name):
end_char = ", " if i < len(no_result_name) - 1 else ""
print(name, end=end_char)
update_channel_urls_txt("🈳无结果频道", name, [])
write_content_into_txt(f"{name},url", path)
print()

@ -16,7 +16,7 @@ txt_pattern = r"^([^,]+)(?:[,])(?!#genre#)" + r"(" + url_pattern + r")"
m3u_pattern = r"^#EXTINF:-1.*?(?:|,)(.*?)\n" + r"(" + url_pattern + r")"
sub_pattern = r"-|_|\((.*?)\)|\(.*?)\|\[(.*?)\]|\「(.*?)\」| ||频道|普清|标清|高清|HD|hd|超清|超高|超高清|中央|央视|台|电信|联通|移动"
sub_pattern = r"-|_|\((.*?)\)|\(.*?)\|\[(.*?)\]|\「(.*?)\」| ||频道|普清|标清|高清|HD|hd|超清|超高|超高清|中央|央视|电视台|台|电信|联通|移动"
replace_dict = {
"plus": "+",
@ -52,6 +52,36 @@ replace_dict = {
"CCTV17农业": "CCTV17",
}
region_list = [
"广东",
"北京",
"湖南",
"湖北",
"浙江",
"上海",
"天津",
"江苏",
"山东",
"河南",
"河北",
"山西",
"陕西",
"安徽",
"重庆",
"福建",
"江西",
"辽宁",
"黑龙江",
"吉林",
"四川",
"云南",
"香港",
"内蒙古",
"甘肃",
"海南",
"云南",
]
origin_map = {
"hotel": "酒店源",
"multicast": "组播源",

@ -499,3 +499,20 @@ def resource_path(relative_path, persistent=False):
return os.path.join(base_path, relative_path)
except Exception:
return total_path
def write_content_into_txt(content, path=None, newline=True, callback=None):
"""
Write content into txt file
"""
if not path:
return
with open(path, "a", encoding="utf-8") as f:
if newline:
f.write(f"\n{content}")
else:
f.write(content)
if callback:
callback()