Skip to content

Commit

Permalink
Merge pull request #468 from Guovin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Guovin authored Oct 28, 2024
2 parents f1683d0 + 5a970d6 commit deab1e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
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

0 comments on commit deab1e1

Please sign in to comment.