Skip to content

Commit

Permalink
providers.json Add ex-node-name parameter to filter nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock committed Mar 26, 2024
1 parent cec3365 commit 5491242
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions instructions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ In this file, you can add subscription links and basic settings.
"emoji": 1, //Add flag emoji
"subgroup": "",
"prefix": "", //Do not add node name prefix
"ex-node-name": "网站|流量|过期", //Filter nodes containing keywords
"User-Agent":"clashmeta" //Set browser UA
},
{
Expand Down Expand Up @@ -270,6 +271,8 @@ In this file, you can add subscription links and basic settings.

- `prefix`: Optional. Set a custom prefix that will be added to the beginning of the node names. If not set, no prefix will be added.

- `ex-node-name`: Optional. Filter nodes containing keywords. Multiple keywords are separated by "|"

- `User-Agent`: Optional. You can customize UA, such as setting UA to "clash.meta" or "sing-box"

<details>
Expand Down
10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def process_subscribes(subscribes):
if _nodes and len(_nodes) > 0:
add_prefix(_nodes, subscribe)
add_emoji(_nodes, subscribe)
nodefilter(_nodes, subscribe)
if subscribe.get('subgroup'):
subscribe['tag'] = subscribe['tag'] + '-' + subscribe['subgroup'] + '-' + 'subgroup'
if not nodes.get(subscribe['tag']):
Expand Down Expand Up @@ -120,6 +121,15 @@ def add_emoji(nodes, subscribe):
node['detour'] = tool.rename(node['detour'])


def nodefilter(nodes, subscribe):
if subscribe.get('ex-node-name'):
ex_nodename = subscribe['ex-node-name'].split('|')
for exns in ex_nodename:
for node in nodes[:]: # 遍历 nodes 的副本,以便安全地删除元素
if exns in node['tag']:
nodes.remove(node)


def get_nodes(url):
if url.startswith('sub://'):
url = tool.b64Decode(url[6:]).decode('utf-8')
Expand Down

1 comment on commit 5491242

@Toperlock
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#64

Please sign in to comment.