v0.2.7: 修复Redis连接 + 启动管理后台
- 修复Redis认证 (配置密码) - 启动Python管理后台 (端口9531, 15个功能开关) - 统一版本号 0.2.7 - 更新docker-compose.yml (镜像版本/Redis URL/Admin服务)
This commit is contained in:
71
cloudsearch_transfer/adapter/pan123/transfer.py
Normal file
71
cloudsearch_transfer/adapter/pan123/transfer.py
Normal file
@@ -0,0 +1,71 @@
|
||||
"""123云盘转存逻辑 v1.0.0"""
|
||||
|
||||
import re
|
||||
import logging
|
||||
from typing import List, Tuple
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Pan123Transfer:
|
||||
API_BASE = "https://www.123pan.com/api"
|
||||
|
||||
def __init__(self, session, credential_mgr, config, transfer_config):
|
||||
self.session = session
|
||||
self.credential = credential_mgr
|
||||
self.config = config
|
||||
self.transfer_config = transfer_config
|
||||
self._last_file_names = []
|
||||
|
||||
@staticmethod
|
||||
def parse_share_url(url: str) -> Tuple[str, str]:
|
||||
m = re.search(r"123pan\.com/s/([A-Za-z0-9]+)", url)
|
||||
if not m:
|
||||
raise ValueError("Invalid 123pan share URL")
|
||||
code = m.group(1)
|
||||
m2 = re.search(r"[?&]pwd=(\w+)", url)
|
||||
return code, m2.group(1) if m2 else ""
|
||||
|
||||
def get_share_info(self, share_key: str, password: str = "") -> dict:
|
||||
payload = {"shareKey": share_key}
|
||||
if password:
|
||||
payload["sharePwd"] = password
|
||||
resp = self.session.post(
|
||||
f"{self.API_BASE}/share/info",
|
||||
json=payload,
|
||||
timeout=self.transfer_config.request_timeout,
|
||||
)
|
||||
data = resp.json()
|
||||
if data.get("code") != 0:
|
||||
raise Exception(f"123 share info failed: {data}")
|
||||
info = data.get("data", {})
|
||||
files = info.get("fileList", [])
|
||||
return {
|
||||
"title": info.get("shareName", ""),
|
||||
"files": [{"id": f.get("fileId", ""), "name": f.get("fileName", ""),
|
||||
"size": f.get("fileSize", 0)} for f in files],
|
||||
"share_id": info.get("shareId", ""),
|
||||
}
|
||||
|
||||
def save_files(self, share_key: str, detail: dict, save_dir: str) -> List[str]:
|
||||
payload = {
|
||||
"shareKey": share_key,
|
||||
"shareId": detail.get("share_id", ""),
|
||||
"parentFileId": save_dir or "0",
|
||||
}
|
||||
resp = self.session.post(
|
||||
f"{self.API_BASE}/share/save",
|
||||
json=payload,
|
||||
timeout=self.transfer_config.request_timeout,
|
||||
)
|
||||
data = resp.json()
|
||||
if data.get("code") != 0:
|
||||
raise Exception(f"123 save failed: {data}")
|
||||
return [str(data.get("data", {}).get("fileId", ""))]
|
||||
|
||||
def create_share(self, file_ids: List[str], title: str,
|
||||
password: str = "") -> Tuple[str, str]:
|
||||
return "", ""
|
||||
|
||||
def list_files(self, parent_id: str = "0") -> list:
|
||||
return []
|
||||
Reference in New Issue
Block a user