Update subscription.py

This commit is contained in:
Egor
2026-01-19 22:51:57 +03:00
committed by GitHub
parent 93227b7f41
commit 1e1c0e89bc
+6 -61
View File
@@ -1796,51 +1796,6 @@ def _convert_remnawave_block_to_step(block: Dict[str, Any], url_scheme: str = ""
return step
# Known app URL schemes (fallback if RemnaWave doesn't provide urlScheme)
KNOWN_APP_URL_SCHEMES = {
# iOS
"happ": "happ://add/",
"streisand": "streisand://import/",
"shadowrocket": "sub://",
"shadow rocket": "sub://",
"karing": "karing://install-config?url=",
"foxray": "foxray://yiguo.dev/sub/add/?url=",
"fox ray": "foxray://yiguo.dev/sub/add/?url=",
"v2box": "v2box://install-sub?url=",
"sing-box": "sing-box://import-remote-profile?url=",
"singbox": "sing-box://import-remote-profile?url=",
"quantumult x": "quantumult-x://add-resource?remote-resource=",
"quantumultx": "quantumult-x://add-resource?remote-resource=",
"quantumult": "quantumult-x://add-resource?remote-resource=",
"surge": "surge3://install-config?url=",
"loon": "loon://import?sub=",
"stash": "stash://install-config?url=",
# Android
"v2rayn": "v2rayng://install-sub?url=",
"v2rayng": "v2rayng://install-sub?url=",
"v2ray ng": "v2rayng://install-sub?url=",
"nekoray": "sn://subscription?url=",
"nekobox": "sn://subscription?url=",
"neko ray": "sn://subscription?url=",
"neko box": "sn://subscription?url=",
"surfboard": "surfboard://install-config?url=",
# PC (Windows/macOS/Linux)
"clash": "clash://install-config?url=",
"clash meta": "clash://install-config?url=",
"clash verge": "clash://install-config?url=",
"clash verge rev": "clash://install-config?url=",
"clashx": "clashx://install-config?url=",
"clashx meta": "clash://install-config?url=",
"clashx pro": "clash://install-config?url=",
"flclash": "clash://install-config?url=",
"flclashx": "clash://install-config?url=",
"koala clash": "clash://install-config?url=",
"koalaclash": "clash://install-config?url=",
"hiddify": "hiddify://install-config/?url=",
"hiddify next": "hiddify://install-config/?url=",
"mihomo party": "clash://install-config?url=",
"mihomo": "clash://install-config?url=",
}
def _convert_remnawave_app_to_cabinet(app: Dict[str, Any]) -> Dict[str, Any]:
@@ -1848,11 +1803,6 @@ def _convert_remnawave_app_to_cabinet(app: Dict[str, Any]) -> Dict[str, Any]:
blocks = app.get("blocks", [])
url_scheme = app.get("urlScheme", "")
# If urlScheme is missing, try to determine from app name
if not url_scheme:
app_name = app.get("name", "").lower().strip()
url_scheme = KNOWN_APP_URL_SCHEMES.get(app_name, "")
# Map blocks to steps based on position
installation_step = _convert_remnawave_block_to_step(blocks[0], url_scheme) if len(blocks) > 0 else {"description": {}}
subscription_step = _convert_remnawave_block_to_step(blocks[1], url_scheme) if len(blocks) > 1 else {"description": {}}
@@ -1886,7 +1836,7 @@ def _convert_remnawave_app_to_cabinet(app: Dict[str, Any]) -> Dict[str, Any]:
"id": app.get("name", "").lower().replace(" ", "-"),
"name": app.get("name", ""),
"isFeatured": app.get("featured", False),
"urlScheme": url_scheme, # Use resolved url_scheme (with fallback from app name)
"urlScheme": url_scheme,
"isNeedBase64Encoding": app.get("isNeedBase64Encoding", False),
"installationStep": installation_step,
"addSubscriptionStep": subscription_step,
@@ -1967,21 +1917,16 @@ def _load_app_config() -> Dict[str, Any]:
def _create_deep_link(app: Dict[str, Any], subscription_url: str) -> Optional[str]:
"""Create deep link for app with subscription URL."""
"""Create deep link for app with subscription URL.
Uses urlScheme from RemnaWave config directly without any fallbacks.
"""
if not subscription_url or not isinstance(app, dict):
logger.debug(f"_create_deep_link: no subscription_url or invalid app")
return None
scheme = str(app.get("urlScheme", "")).strip()
if not scheme:
# Try fallback from app name
app_name = app.get("name", "").lower().strip()
scheme = KNOWN_APP_URL_SCHEMES.get(app_name, "")
if scheme:
logger.info(f"_create_deep_link: used fallback urlScheme for '{app_name}': {scheme}")
if not scheme:
logger.warning(f"_create_deep_link: no urlScheme for app '{app.get('name', 'unknown')}'")
logger.debug(f"_create_deep_link: no urlScheme for app '{app.get('name', 'unknown')}'")
return None
payload = subscription_url