兼容虎牙四段账号格式
支持虎牙号、密码、手机号、验证码链接导入,并补充美国等国际手机号格式处理。
This commit is contained in:
+19
-6
@@ -6,6 +6,7 @@ import json
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
|
||||
@@ -42,24 +43,36 @@ class SmsPollResult:
|
||||
|
||||
|
||||
def parse_sms_lines(text: str) -> list[SmsLine]:
|
||||
"""解析手机号池,每行格式:手机号----查询URL。"""
|
||||
"""解析手机号池,兼容手机号----查询URL、账号----密码----手机号----查询URL。"""
|
||||
rows: list[SmsLine] = []
|
||||
for raw_line in (text or "").splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
parts = [part.strip() for part in line.split("----", 1)]
|
||||
if len(parts) != 2 or not parts[0] or not parts[1]:
|
||||
parts = [part.strip() for part in line.split("----")]
|
||||
if len(parts) >= 4 and _looks_like_url("----".join(parts[3:])):
|
||||
phone, url = parts[2], "----".join(parts[3:]).strip()
|
||||
elif len(parts) >= 2 and _looks_like_url("----".join(parts[1:])):
|
||||
phone, url = parts[0], "----".join(parts[1:]).strip()
|
||||
else:
|
||||
continue
|
||||
if not phone or not url:
|
||||
continue
|
||||
rows.append(SmsLine(
|
||||
phone=parts[0],
|
||||
url=parts[1],
|
||||
provider=detect_provider(parts[1]),
|
||||
phone=phone,
|
||||
url=url,
|
||||
provider=detect_provider(url),
|
||||
raw=line,
|
||||
))
|
||||
return rows
|
||||
|
||||
|
||||
def _looks_like_url(value: str) -> bool:
|
||||
"""判断文本是否像 URL。"""
|
||||
parsed = urlparse(str(value or "").strip())
|
||||
return parsed.scheme in {"http", "https"} and bool(parsed.netloc)
|
||||
|
||||
|
||||
def detect_provider(url: str) -> str:
|
||||
"""根据 URL 判断接码平台类型。"""
|
||||
text = (url or "").lower()
|
||||
|
||||
Reference in New Issue
Block a user