INNER CODE UNIT · Python

_b64decode

ermaozi/get_subscribe · main.py:54

def _b64decode(text):
    compact = re.sub(r"\s+", "", text)
    if not compact:
        return ""
    try:
        # binascii.Error 是 ValueError 的子类,统一捕获即可
        raw = base64.b64decode(compact + "=" * (-len(compact) % 4), validate=True)
    except ValueError:
        return ""
    try:
        return raw.decode("utf-8")
    except UnicodeDecodeError:
        return ""


def _detect_kind(text):
    """根据下载内容判断订阅类型:'clash' / 'v2ray',无法识别返回 None。"""
    sample = text.strip()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…