Skip to main content

misub

misub 是一个面向 Mihomo/Clash Meta 的本地订阅构建器。它从多个本地订阅 YAML 中抽取节点,按本地配置重新生成节点列表和代理组,避免依赖机场提供的分组与规则。

功能特性

  • 从多个本地 Clash/Mihomo 订阅文件读取 proxies 节点。
  • 使用 sources[].name 显式标记节点来源,不从节点名猜测机场。
  • 通过 regions 配置识别地区,通过 exclude.contains 过滤套餐、流量、到期等非节点项。
  • 使用 naming 模板输出短节点名,并在重名时自动追加后缀。
  • 使用接近 Mihomo 原生结构的 proxy-groups 配置。
  • 支持 @region:地区@source:来源@all 代理组占位符。
  • 可通过 preserve-base-proxies 保留 base.yaml 中手写的静态代理。
  • 默认只输出最终配置文件,不生成额外报告文件。

安装

开发版可在项目根目录安装:

pip install -e .

开发和测试依赖可使用额外依赖安装:

pip install -e ".[dev]"

快速开始

生成默认配置:

misub init

根据当前目录的 misub.yaml 构建配置:

misub build

指定配置文件构建:

misub build -c /path/to/misub.yaml

配置示例

base: ./base.yaml
output: ./config.yaml
preserve-base-proxies: false

sources:
  - name: provider-a
    path: ./profiles/provider-a.yaml
  - name: provider-b
    path: ./profiles/provider-b.yaml

regions:
  日本: [日本, JP, Japan, Tokyo, 东京]
  新加坡: [新加坡, SG, Singapore, 狮城]
  香港: [香港, , HK, Hong Kong]
  台湾: [台湾, , TW, Taiwan]
  美国: [美国, US, USA, United States, 洛杉矶, LA]

exclude:
  contains: [流量, 到期, 过期, 官网, 套餐, 剩余, 网址, 群组]

naming: "{source}-{region}-{number}"

proxy-groups:
  - name: 节点选择
    type: select
    proxies:
      - 区域-日本
      - 区域-香港
      - DIRECT

  - name: 区域-日本
    type: fallback
    url: https://www.gstatic.com/generate_204
    interval: 300
    proxies:
      - "@region:日本"

  - name: 区域-香港
    type: fallback
    url: https://www.gstatic.com/generate_204
    interval: 300
    proxies:
      - "@region:香港"

构建规则

构建时会读取 base 指向的基础 Mihomo 配置,保留其中除 proxiesproxy-groups 外的字段,然后写入重新生成的节点和代理组。base.yaml 中未被覆盖字段的注释、引号以及 |> 等块标量样式会尽量保留。生成的 proxies 节点和 proxy-groups 代理组使用单行 flow style 输出,减少最终配置文件长度。

默认情况下,输出的 proxies 只包含订阅来源中的保留节点。若 base.yaml 中存在手写静态代理,并且 rules 或代理组会引用这些代理,可设置:

preserve-base-proxies: true

开启后,base.yaml 中原有 proxies 会保留在输出节点列表前部,订阅节点会追加在其后。

节点命名默认使用:

{source}-{region}-{number}

编号优先从原始节点名中提取;无法提取时,在相同来源和地区内递增生成。无法识别地区的节点会归入 未识别,不会被默认丢弃。

占位符

占位符 含义
@region:日本 展开为所有识别为日本的节点名
@source:provider-a 展开为 provider-a 来源的所有节点名
@all 展开为所有保留节点名

未知 @ 占位符会导致构建失败,避免静默生成错误配置。

测试

python -m pytest -v

设计文档

详细设计见 docs/2026-04-30-misub-design.md

License

项目尚未声明许可证。发布到公开仓库前应补充许可证文件。

Download files

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

Source Distribution

misub-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

misub-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for misub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6cf00071e328108c5cea018987261c9625e72571e1a39bc30ac44b10c1cc3a08
MD5 fd75b872b3ea0ade283b2bb3535258af
BLAKE2b-256 f102abb2c7e2aaacac412ec960f123a3db6edb3483bf4a73fae4be7246e2f9fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: misub-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for misub-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62e3d83200ab925bbc45a9dd0aded0a4325a42c1724bf8c095ad619be2646965
MD5 3a55dabaa8d6a069ceaa72780b8af776
BLAKE2b-256 dc87fe64cd84e59fd7d8d711a247efaeb16c481e3d44e2b214793d3bcfb881c3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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