FongMi 5以上版本支持
This commit is contained in:
@@ -27,8 +27,6 @@ jobs:
|
|||||||
# cd ../
|
# cd ../
|
||||||
# shell: bash
|
# shell: bash
|
||||||
- name: xiaosa tools
|
- name: xiaosa tools
|
||||||
env:
|
|
||||||
CF_PROXY_URL: ${{ secrets.CF_PROXY_URL }}
|
|
||||||
run: |
|
run: |
|
||||||
pwd
|
pwd
|
||||||
cd tools/
|
cd tools/
|
||||||
|
|||||||
+22
-24
@@ -137,7 +137,28 @@ class TVBox本地构建器:
|
|||||||
print(f"\n=== 下载 Spider ===")
|
print(f"\n=== 下载 Spider ===")
|
||||||
url = self.替换代理域名(url)
|
url = self.替换代理域名(url)
|
||||||
|
|
||||||
# 方案1: 用 requests 下载
|
# 方案1: 通过 CF Worker 代理下载(优先)
|
||||||
|
cf_proxy = 'https://wild-butterfly-88a5.juestnow.workers.dev'
|
||||||
|
try:
|
||||||
|
proxy_url = f"{cf_proxy}?q={url}"
|
||||||
|
print(f" 下载(cf-proxy): {proxy_url[:80]}...")
|
||||||
|
resp = self.session.get(proxy_url, timeout=60, allow_redirects=True)
|
||||||
|
resp.raise_for_status()
|
||||||
|
content = resp.content
|
||||||
|
if len(content) > 1000 and content[:2] == b'PK':
|
||||||
|
with open(spider_path, 'wb') as f:
|
||||||
|
f.write(content)
|
||||||
|
md5 = self.计算MD5(spider_path)
|
||||||
|
print(f" ✓ cf-proxy保存到: {spider_path}")
|
||||||
|
print(f" MD5: {md5}")
|
||||||
|
self.数据['spider'] = f"./spider.jar;md5;{md5}"
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print(f" ✗ cf-proxy返回内容非有效jar (大小: {len(content)})")
|
||||||
|
except Exception as e:
|
||||||
|
print(f" ✗ cf-proxy下载失败: {e}")
|
||||||
|
|
||||||
|
# 方案2: 用 requests 直接下载
|
||||||
try:
|
try:
|
||||||
print(f" 下载(requests): {url}")
|
print(f" 下载(requests): {url}")
|
||||||
resp = self.session.get(url, timeout=30, allow_redirects=True)
|
resp = self.session.get(url, timeout=30, allow_redirects=True)
|
||||||
@@ -152,29 +173,6 @@ class TVBox本地构建器:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" ✗ requests下载失败: {e}")
|
print(f" ✗ requests下载失败: {e}")
|
||||||
|
|
||||||
# 方案2: 通过 CF Worker 代理下载
|
|
||||||
cf_proxy = os.environ.get('CF_PROXY_URL', '')
|
|
||||||
if cf_proxy:
|
|
||||||
try:
|
|
||||||
proxy_url = f"{cf_proxy}?q={url}"
|
|
||||||
print(f" 下载(cf-proxy): {proxy_url[:80]}...")
|
|
||||||
resp = self.session.get(proxy_url, timeout=60, allow_redirects=True)
|
|
||||||
resp.raise_for_status()
|
|
||||||
content = resp.content
|
|
||||||
# 检查是否为有效 jar 文件(PK 开头 = zip/jar)
|
|
||||||
if len(content) > 1000 and content[:2] == b'PK':
|
|
||||||
with open(spider_path, 'wb') as f:
|
|
||||||
f.write(content)
|
|
||||||
md5 = self.计算MD5(spider_path)
|
|
||||||
print(f" ✓ cf-proxy保存到: {spider_path}")
|
|
||||||
print(f" MD5: {md5}")
|
|
||||||
self.数据['spider'] = f"./spider.jar;md5;{md5}"
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print(f" ✗ cf-proxy返回内容非有效jar (大小: {len(content)})")
|
|
||||||
except Exception as e:
|
|
||||||
print(f" ✗ cf-proxy下载失败: {e}")
|
|
||||||
|
|
||||||
# 方案3: 使用已有的 spider.jar(从上级目录查找)
|
# 方案3: 使用已有的 spider.jar(从上级目录查找)
|
||||||
import shutil
|
import shutil
|
||||||
for candidate in [Path('../xiaosa/spider.jar'), Path('../jar/spider.jar'), Path('spider.jar')]:
|
for candidate in [Path('../xiaosa/spider.jar'), Path('../jar/spider.jar'), Path('spider.jar')]:
|
||||||
|
|||||||
+12
-9
@@ -40,6 +40,18 @@ class 文件加解密器:
|
|||||||
encoded_netloc = quote(parsed.netloc, safe='')
|
encoded_netloc = quote(parsed.netloc, safe='')
|
||||||
url = parsed._replace(netloc=encoded_netloc).geturl()
|
url = parsed._replace(netloc=encoded_netloc).geturl()
|
||||||
|
|
||||||
|
# 优先通过 CF Worker 代理下载
|
||||||
|
cf_proxy = 'https://wild-butterfly-88a5.juestnow.workers.dev'
|
||||||
|
proxy_url = f"{cf_proxy}?q={url}"
|
||||||
|
try:
|
||||||
|
req = Request(proxy_url, headers={
|
||||||
|
'User-Agent': 'okhttp/3.12.0',
|
||||||
|
'Accept-Encoding': 'gzip, deflate'
|
||||||
|
})
|
||||||
|
with urlopen(req, timeout=30) as response:
|
||||||
|
raw_content = response.read()
|
||||||
|
except Exception as cf_err:
|
||||||
|
print(f" CF代理失败,尝试直连: {cf_err}")
|
||||||
req = Request(url, headers={
|
req = Request(url, headers={
|
||||||
'User-Agent': 'okhttp/3.12.0',
|
'User-Agent': 'okhttp/3.12.0',
|
||||||
'Accept-Encoding': 'gzip, deflate'
|
'Accept-Encoding': 'gzip, deflate'
|
||||||
@@ -47,11 +59,6 @@ class 文件加解密器:
|
|||||||
with urlopen(req, timeout=30) as response:
|
with urlopen(req, timeout=30) as response:
|
||||||
raw_content = response.read()
|
raw_content = response.read()
|
||||||
|
|
||||||
# 检查是否为图片或二进制文件
|
|
||||||
content_type = response.headers.get('Content-Type', '')
|
|
||||||
if content_type.startswith('image/') or content_type.startswith('video/') or content_type.startswith('audio/'):
|
|
||||||
print(f" 检测到{content_type}类型,尝试提取嵌入的数据...")
|
|
||||||
|
|
||||||
# 检查文件头是否为常见图片格式
|
# 检查文件头是否为常见图片格式
|
||||||
image_headers = [
|
image_headers = [
|
||||||
b'\xff\xd8\xff\xe0', # JPEG
|
b'\xff\xd8\xff\xe0', # JPEG
|
||||||
@@ -120,15 +127,12 @@ class 文件加解密器:
|
|||||||
|
|
||||||
if not is_hex:
|
if not is_hex:
|
||||||
try:
|
try:
|
||||||
# 尝试base64解码
|
|
||||||
decoded = base64.b64decode(content)
|
decoded = base64.b64decode(content)
|
||||||
# 解码后再次尝试gzip解压
|
|
||||||
try:
|
try:
|
||||||
decoded = gzip.decompress(decoded)
|
decoded = gzip.decompress(decoded)
|
||||||
print(f" ✓ base64+gzip解码成功")
|
print(f" ✓ base64+gzip解码成功")
|
||||||
except:
|
except:
|
||||||
print(f" ✓ base64解码成功")
|
print(f" ✓ base64解码成功")
|
||||||
# 将解码后的内容转为字符串
|
|
||||||
for encoding in ['utf-8', 'gbk', 'gb2312', 'latin-1']:
|
for encoding in ['utf-8', 'gbk', 'gb2312', 'latin-1']:
|
||||||
try:
|
try:
|
||||||
content = decoded.decode(encoding)
|
content = decoded.decode(encoding)
|
||||||
@@ -136,7 +140,6 @@ class 文件加解密器:
|
|||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
# 不是base64格式,继续使用原内容
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print(f"✓ 成功获取URL内容 ({len(content)} 字节)")
|
print(f"✓ 成功获取URL内容 ({len(content)} 字节)")
|
||||||
|
|||||||
Reference in New Issue
Block a user