chore:whitelist info

This commit is contained in:
guorong.zheng 2024-12-23 14:17:01 +08:00
parent 2c37fe332c
commit 37938a3e3d
3 changed files with 11 additions and 11 deletions

@ -55,12 +55,12 @@ def get_channel_data_from_file(channels, file, use_old, whitelist):
category_dict[name] = []
if name in whitelist:
for whitelist_url in whitelist[name]:
category_dict[name].append((whitelist_url, None, None, "important"))
category_dict[name].append((whitelist_url, None, None, "whitelist"))
if use_old and url:
info = url.partition("$")[2]
origin = None
if info and info.startswith("!"):
origin = "important"
origin = "whitelist"
data = (url, None, None, origin)
if data not in category_dict[name]:
category_dict[name].append(data)
@ -102,7 +102,7 @@ def get_channel_items():
for info in old_result[cate][name]:
if info:
try:
if info[3] == "important" and not any(
if info[3] == "whitelist" and not any(
url in info[0] for url in whitelist_urls):
continue
except:
@ -460,9 +460,9 @@ def append_data_to_info_data(info_data, cate, name, data, origin=None, check=Tru
if pure_url in urls:
continue
if whitelist and check_url_by_keywords(url, whitelist):
url_origin = "important"
url_origin = "whitelist"
if (
url_origin == "important"
url_origin == "whitelist"
or (not check)
or (
check and check_url_ipv_type(pure_url) and not check_url_by_keywords(url, blacklist))

@ -277,7 +277,7 @@ def sort_urls(name, data, logger=None):
"resolution": resolution,
"origin": origin
}
if origin == "important":
if origin == "whitelist":
filter_data.append(result)
continue
cache_key_match = re.search(r"cache:(.*)", url.partition("$")[2])
@ -304,7 +304,7 @@ def sort_urls(name, data, logger=None):
def combined_key(item):
speed, origin = item["speed"], item["origin"]
if origin == "important":
if origin == "whitelist":
return float("inf")
else:
return speed if speed is not None else float("-inf")

@ -157,10 +157,10 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer):
if not origin:
continue
if origin == "important":
im_url, _, im_info = url.partition("$")
im_info_value = im_info.partition("!")[2]
total_urls.append(f"{im_url}${im_info_value}" if im_info_value else im_url)
if origin == "whitelist":
w_url, _, w_info = url.partition("$")
w_info_value = w_info.partition("!")[2] or "白名单"
total_urls.append(add_url_info(w_url, w_info_value))
continue
if origin == "subscribe" and "/rtp/" in url: