Skip to content

dzhuang/sing-box-converter

 
 

Repository files navigation

SingBox Converter

The code are refactored from Toperlock/sing-box-subscribe See Documentation.

How to install

pip install PySingBoxConverter

Use in commandline

Create a providers.json from providers-example.json:

cp providers-example.json providers.json

vi providers.json

Then run

singbox_convert -t 1 -o config1.json

Use in python code systematically

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
)

Thanks

Credit goes to: