Skip to main content

Python-based proxy subscription converter for Clash

Project description

py-subconverter

Python-based proxy subscription converter for Clash. Convert proxy subscriptions to Clash configuration format with full support for subconverter INI configurations.

Features

  • ✅ Convert proxy subscriptions to Clash YAML format
  • ✅ Support for Shadowsocks, VMess, Trojan, VLESS protocols
  • ✅ Full subconverter INI configuration support
  • ✅ Custom proxy groups with regex matching
  • ✅ Rule-based routing with automatic rule set downloading
  • ✅ Filter unsupported rule types automatically
  • ✅ No external services required - 100% local conversion

Installation

pip install py-subconverter

Quick Start

Command Line Usage

Basic conversion:

py-sub-conv --output config.yaml

With environment variables (.env file):

DLER_EMAIL=your@email.com
DLER_PASSWORD=yourpassword
RULE_URL=https://example.com/config.ini

Then run:

py-sub-conv --output config.yaml

Python API Usage

from py_subconverter import SubscriptionConverter

converter = SubscriptionConverter()

# Convert subscription
config = converter.convert(
    subscription_url="https://example.com/subscription",
    rule_url="https://example.com/config.ini",  # Optional INI config
    output_file="config.yaml"
)

Supported Rule Types

py-subconverter automatically filters rules to only include types supported by standard Clash:

  • DOMAIN - Match exact domain
  • DOMAIN-SUFFIX - Match domain suffix
  • DOMAIN-KEYWORD - Match domain keyword
  • IP-CIDR - Match IPv4 CIDR
  • IP-CIDR6 - Match IPv6 CIDR
  • GEOIP - Match GeoIP database
  • MATCH - Match all (final rule)
  • PROCESS-NAME - Match process name

Automatically filtered (Clash Meta only):

  • USER-AGENT
  • URL-REGEX

INI Configuration Support

py-subconverter fully supports subconverter INI format:

[custom]
ruleset=🎯 Direct,https://example.com/rules/direct.list
ruleset=🚀 Proxy,https://example.com/rules/proxy.list
ruleset=🐟 Final,[]MATCH

custom_proxy_group=🚀 Proxy`select`[]♻️ Auto`[]🇭🇰 HK`[]DIRECT
custom_proxy_group=♻️ Auto`url-test`.*`http://www.gstatic.com/generate_204`300
custom_proxy_group=🇭🇰 HK`url-test`香港|HK`http://www.gstatic.com/generate_204`300

CLI Options

py-sub-conv [OPTIONS]

Options:
  -o, --output FILE         Output YAML file path (default: config.yaml)
  -s, --subscription URL    Subscription URL (overrides .env)
  -r, --rule URL           Custom rule URL (overrides .env)
  -v, --verbose            Show detailed conversion process
  -h, --help               Show this help message

Development

Setup Development Environment

git clone https://github.com/gencylee/py-subconverter.git
cd py-subconverter

# Install in development mode
pip install -e ".[dev]"

Run Tests

pytest

Build Package

python -m build

Differences from Original Subconverter

py-subconverter is a pure Python implementation that:

  1. No External Services - All conversion is done locally
  2. Better Performance - Direct Python implementation without HTTP overhead
  3. Rule Filtering - Automatically filters unsupported rule types
  4. Modern Python - Clean, maintainable codebase with type hints

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subconverter_py-0.1.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subconverter_py-0.1.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file subconverter_py-0.1.0.tar.gz.

File metadata

  • Download URL: subconverter_py-0.1.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for subconverter_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62f40e328b1a4c752864a5bb0a103aa5fba4974c1b6333d96e52f088eabd438f
MD5 a2a76f994eca24564765eeddf5afc98e
BLAKE2b-256 5394111be860368ba119f58892eb462ebc5df364bb4b5951e6e9dd42c0e615be

See more details on using hashes here.

File details

Details for the file subconverter_py-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for subconverter_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b7665da2d8f34bb53089bccc61eb120b603ac04129c1f259293a75b9a91639c
MD5 daa86d4f0478d3191909c2035f614bd2
BLAKE2b-256 762490d8b78d3625ae5611a978c738c8fa654d3d5e3cedef3d1243b2b8530588

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page