rogerxavier commited on
Commit
c4083d1
·
verified ·
1 Parent(s): 18dbfcc

Upload getServerList.py

Browse files
Files changed (1) hide show
  1. getServerList.py +11 -1
getServerList.py CHANGED
@@ -23,6 +23,7 @@ def getServerList(background_tasks: BackgroundTasks)->str:
23
  except Exception as e:
24
  # 如果解析失败,打印错误信息并继续处理下一个订阅链接
25
  print(f"解析订阅链接 {subscribe_url} 时发生错误: {e}")
 
26
 
27
  # 将所有节点拼接成一个字符串,每个节点之间用换行符分隔
28
  combined_links = "\n".join(all_node_lists)
@@ -41,4 +42,13 @@ def getServerList(background_tasks: BackgroundTasks)->str:
41
  def dump_configs(url:str)->list:
42
  #返回全部节点信息的列表
43
  configs = decode_url_to_configs(url)
44
- return configs
 
 
 
 
 
 
 
 
 
 
23
  except Exception as e:
24
  # 如果解析失败,打印错误信息并继续处理下一个订阅链接
25
  print(f"解析订阅链接 {subscribe_url} 时发生错误: {e}")
26
+ all_node_lists = get_unique_node_list(all_node_lists) # 去重且不改变顺序
27
 
28
  # 将所有节点拼接成一个字符串,每个节点之间用换行符分隔
29
  combined_links = "\n".join(all_node_lists)
 
42
  def dump_configs(url:str)->list:
43
  #返回全部节点信息的列表
44
  configs = decode_url_to_configs(url)
45
+ return configs
46
+
47
+ # 删除jms解析导致的重复节点
48
+ def get_unique_node_list(NodeList:list)->list:
49
+ unique_node_list = []
50
+ for node in NodeList:
51
+ if node not in unique_node_list:
52
+ unique_node_list.append(node)
53
+ NodeList = unique_node_list
54
+ return NodeList