The code are refactored from Toperlock/sing-box-subscribe See Documentation.
pip install PySingBoxConverter
Create a providers.json
from providers-example.json
:
cp providers-example.json providers.json
vi providers.json
singbox_convert -t 1 -o config1.json
from singbox_converter import SingBoxConverter
converter = SingBoxConverter(
providers_config="/path/to/providers.json",
template="/path/to/template",
fetch_sub_ua="clash.meta",
# fetch_sub_fallback_ua="clash",
# export_config_folder="",
# export_config_name="my_config.json",
# auto_fix_empty_outbound=True,
)
print(converter.singbox_config)
converter.export_config(
path="/path/to/output/config",
# nodes_only=True
)
Credit goes to: