Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #469

Merged
merged 5 commits into from
Oct 28, 2024
Merged

Fix #469

Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
## 特点

- 自定义模板,生成您想要的频道
- 支持多种获取源方式:组播源、酒店源、订阅源、线上检索
- 支持多种获取源方式:组播源、酒店源、订阅源、关键字搜索
- 接口测速验效,响应时间、分辨率优先级,过滤无效接口
- 定时执行,北京时间每日 6:00 与 18:00 执行更新
- 支持多种运行方式:工作流、命令行、GUI 软件、Docker(amd64/arm64)
Expand Down
2 changes: 1 addition & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
## Features

- Customize the template to generate the channel you want
- Supports multiple source acquisition methods: multicast source, hotel source, subscription source, online search
- Supports multiple source acquisition methods: multicast source, hotel source, subscription source, keyword search
- Interface speed testing and verification, with priority on response time and resolution, filtering out ineffective interfaces
- Scheduled execution at 6:00 AM and 18:00 PM Beijing time daily
- Supports various execution methods: workflows, command line, GUI software, Docker(amd64/arm64)
Expand Down
16 changes: 12 additions & 4 deletions utils/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ def get_channel_items():
return channels


open_keep_all = config.getboolean("Settings", "open_keep_all", fallback=False)


def format_channel_name(name):
"""
Format the channel name with sub and replace and lower
"""
if config.getboolean("Settings", "open_keep_all", fallback=False):
if open_keep_all:
return name
cc = OpenCC("t2s")
name = cc.convert(name)
Expand Down Expand Up @@ -183,7 +186,7 @@ def channel_name_is_equal(name1, name2):
"""
Check if the channel name is equal
"""
if config.getboolean("Settings", "open_keep_all", fallback=False):
if open_keep_all:
return True
name1_format = format_channel_name(name1)
name2_format = format_channel_name(name2)
Expand Down Expand Up @@ -530,7 +533,7 @@ def append_total_data(*args, **kwargs):
"""
Append total channel data
"""
if config.getboolean("Settings", "open_keep_all", fallback=False):
if open_keep_all:
append_all_method_data_keep_all(*args, **kwargs)
else:
append_all_method_data(*args, **kwargs)
Expand Down Expand Up @@ -781,7 +784,12 @@ def write_channel_to_file(items, data, ipv6=False, callback=None):
now += datetime.timedelta(hours=8)
update_time = now.strftime("%Y-%m-%d %H:%M:%S")
update_channel_urls_txt("更新时间", f"{update_time}", ["url"])
for cate, channel_obj in items:
result_items = (
data.items()
if config.getboolean("Settings", "open_keep_all", fallback=False)
else items
)
for cate, channel_obj in result_items:
print(f"\n{cate}:", end=" ")
channel_obj_keys = channel_obj.keys()
names_len = len(list(channel_obj_keys))
Expand Down
8 changes: 5 additions & 3 deletions utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ def get_total_urls_from_info_list(infoList, ipv6=False):
for origin in origin_type_prefer:
for ipv_type in ipv_type_total:
if ipv_num[ipv_type] < ipv_limit[ipv_type]:
extra_urls = categorized_urls[origin][ipv_type][
source_limits[origin] :
]
extra_urls = (
categorized_urls[origin][ipv_type][source_limits[origin] :]
if ipv_type in ipv_type_prefer
else categorized_urls[origin][ipv_type][: source_limits[origin]]
)
total_urls.extend(extra_urls)
ipv_num[ipv_type] += len(extra_urls)
if len(total_urls) >= urls_limit:
Expand Down
Loading