|
|
@@ -136,6 +136,32 @@ def sort_proxies():
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
+def category_group():
|
|
|
+ # 首先 load 整个分类
|
|
|
+ proxy_groups = config_template['proxy-groups'][0]['proxies']
|
|
|
+
|
|
|
+ hk_group = {'name': '香港', 'type': 'select', 'proxies': []}
|
|
|
+ hk_list = ['HK', '香港']
|
|
|
+ for proxy in proxy_groups:
|
|
|
+ if any(keyword in proxy for keyword in hk_list):
|
|
|
+ hk_group['proxies'].append(proxy)
|
|
|
+
|
|
|
+ if hk_group['proxies']:
|
|
|
+ config_template['proxy-groups'].append(hk_group)
|
|
|
+
|
|
|
+ tw_group = {'name': '台湾', 'type': 'select', 'proxies': []}
|
|
|
+ tw_list = ['TW', '台湾']
|
|
|
+ for proxy in proxy_groups:
|
|
|
+ if any(keyword in proxy for keyword in tw_list):
|
|
|
+ tw_group['proxies'].append(proxy)
|
|
|
+
|
|
|
+ if tw_group['proxies']:
|
|
|
+ config_template['proxy-groups'].append(tw_group)
|
|
|
+
|
|
|
+ first_element = config_template['proxy-groups'].pop(0)
|
|
|
+ config_template['proxy-groups'].append(first_element)
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
process_xfltd()
|
|
|
process_bitz()
|
|
|
@@ -143,7 +169,9 @@ if __name__ == '__main__':
|
|
|
|
|
|
sort_proxies()
|
|
|
|
|
|
- with open('test.yaml', 'w', encoding='utf-8') as file:
|
|
|
+ category_group()
|
|
|
+
|
|
|
+ with open('config.yaml', 'w', encoding='utf-8') as file:
|
|
|
yaml.dump(config_template, file, allow_unicode=True, default_flow_style=False)
|
|
|
|
|
|
print('done!')
|