mirror of
https://github.com/ctwj/urldb.git
synced 2025-11-25 03:15:04 +08:00
fix: 迅雷取shareId失败的问题
This commit is contained in:
@@ -68,7 +68,7 @@ func extractShareID(urlStr string) (string, string) {
|
|||||||
},
|
},
|
||||||
XunleiStr: {
|
XunleiStr: {
|
||||||
Domains: []string{"pan.xunlei.com"},
|
Domains: []string{"pan.xunlei.com"},
|
||||||
Pattern: regexp.MustCompile(`https?://(?:www\.)?pan\.xunlei\.com/s/([a-zA-Z0-9-]+)`),
|
Pattern: regexp.MustCompile(`https?://(?:www\.)?pan\.xunlei\.com/s/([a-zA-Z0-9-_]+)`),
|
||||||
},
|
},
|
||||||
BaiduStr: {
|
BaiduStr: {
|
||||||
Domains: []string{"pan.baidu.com", "yun.baidu.com"},
|
Domains: []string{"pan.baidu.com", "yun.baidu.com"},
|
||||||
|
|||||||
@@ -303,6 +303,19 @@ func (x *XunleiPanService) GetServiceType() ServiceType {
|
|||||||
return Xunlei
|
return Xunlei
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func extractCode(url string) string {
|
||||||
|
// 查找 pwd= 的位置
|
||||||
|
if pwdIndex := strings.Index(url, "pwd="); pwdIndex != -1 {
|
||||||
|
code := url[pwdIndex+4:]
|
||||||
|
// 移除 # 及后面的内容(如果存在)
|
||||||
|
if hashIndex := strings.Index(code, "#"); hashIndex != -1 {
|
||||||
|
code = code[:hashIndex]
|
||||||
|
}
|
||||||
|
return code
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer 转存分享链接 - 实现 PanService 接口,匹配 XunleiPan.php 的逻辑
|
// Transfer 转存分享链接 - 实现 PanService 接口,匹配 XunleiPan.php 的逻辑
|
||||||
func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
||||||
// 读取配置(线程安全)
|
// 读取配置(线程安全)
|
||||||
@@ -324,7 +337,7 @@ func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 转存模式:实现完整的转存流程
|
// 转存模式:实现完整的转存流程
|
||||||
thisCode := strings.TrimLeft(config.URL, "#")
|
thisCode := extractCode(config.URL)
|
||||||
|
|
||||||
// 获取分享详情
|
// 获取分享详情
|
||||||
shareDetail, err := x.getShare(shareID, thisCode, accessToken, captchaToken)
|
shareDetail, err := x.getShare(shareID, thisCode, accessToken, captchaToken)
|
||||||
@@ -332,14 +345,6 @@ func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
|||||||
return ErrorResult(fmt.Sprintf("获取分享详情失败: %v", err)), nil
|
return ErrorResult(fmt.Sprintf("获取分享详情失败: %v", err)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if shareDetail["code"].(int) != 200 {
|
|
||||||
message := "获取分享详情失败"
|
|
||||||
if shareDetail["message"] != nil {
|
|
||||||
message = shareDetail["message"].(string)
|
|
||||||
}
|
|
||||||
return ErrorResult(message), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否为检验模式
|
// 检查是否为检验模式
|
||||||
if config.IsType == 1 {
|
if config.IsType == 1 {
|
||||||
// 检验模式:直接获取分享信息
|
// 检验模式:直接获取分享信息
|
||||||
@@ -350,9 +355,7 @@ func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
|||||||
}
|
}
|
||||||
return SuccessResult("检验成功", urls), nil
|
return SuccessResult("检验成功", urls), nil
|
||||||
}
|
}
|
||||||
|
files := shareDetail["files"].([]interface{})
|
||||||
shareData := shareDetail["data"].(map[string]interface{})
|
|
||||||
files := shareData["files"].([]interface{})
|
|
||||||
|
|
||||||
// 转存到网盘
|
// 转存到网盘
|
||||||
parent_id := "0" // 默认存储路径
|
parent_id := "0" // 默认存储路径
|
||||||
@@ -373,7 +376,7 @@ func (x *XunleiPanService) Transfer(shareID string) (*TransferResult, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 转存资源
|
// 转存资源
|
||||||
restoreResult, err := x.getRestore(shareID, shareData, accessToken, captchaToken, parent_id)
|
restoreResult, err := x.getRestore(shareID, shareDetail, accessToken, captchaToken, parent_id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrorResult(fmt.Sprintf("转存失败: %v", err)), nil
|
return ErrorResult(fmt.Sprintf("转存失败: %v", err)), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
export const useCookie = () => {
|
|
||||||
const get = (name: string): string | null => {
|
|
||||||
if (process.server) {
|
|
||||||
// 服务端处理
|
|
||||||
const { req } = useRequestEvent()
|
|
||||||
const cookies = parse(req.headers.cookie || '')
|
|
||||||
return cookies[name] || null
|
|
||||||
} else {
|
|
||||||
// 客户端处理
|
|
||||||
const cookieString = document.cookie
|
|
||||||
const cookies = cookieString.split('; ')
|
|
||||||
for (const cookie of cookies) {
|
|
||||||
const [cookieName, cookieValue] = cookie.split('=')
|
|
||||||
if (cookieName === name) {
|
|
||||||
return decodeURIComponent(cookieValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const set = (name: string, value: string, options?: any) => {
|
|
||||||
if (process.server) {
|
|
||||||
// 服务端设置 cookie
|
|
||||||
const { res } = useRequestEvent()
|
|
||||||
res.setHeader('Set-Cookie', `${name}=${encodeURIComponent(value)}; ${serializeOptions(options)}`)
|
|
||||||
} else {
|
|
||||||
// 客户端设置 cookie
|
|
||||||
document.cookie = `${name}=${encodeURIComponent(value)}; ${serializeOptions(options)}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const remove = (name: string) => {
|
|
||||||
set(name, '', { maxAge: -1 })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 序列化 cookie 选项
|
|
||||||
const serializeOptions = (options: any = {}): string => {
|
|
||||||
const {
|
|
||||||
maxAge,
|
|
||||||
expires,
|
|
||||||
path = '/',
|
|
||||||
domain,
|
|
||||||
secure,
|
|
||||||
httpOnly,
|
|
||||||
sameSite
|
|
||||||
} = options
|
|
||||||
|
|
||||||
let result = ''
|
|
||||||
|
|
||||||
if (maxAge !== undefined) result += `Max-Age=${maxAge}; `
|
|
||||||
if (expires instanceof Date) result += `Expires=${expires.toUTCString()}; `
|
|
||||||
if (path) result += `Path=${path}; `
|
|
||||||
if (domain) result += `Domain=${domain}; `
|
|
||||||
if (secure) result += 'Secure; '
|
|
||||||
if (httpOnly) result += 'HttpOnly; '
|
|
||||||
if (sameSite) result += `SameSite=${sameSite}; `
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析 cookie 字符串
|
|
||||||
const parse = (cookieString: string): Record<string, string> => {
|
|
||||||
const cookies: Record<string, string> = {}
|
|
||||||
cookieString.split(';').forEach(cookie => {
|
|
||||||
const [name, value] = cookie.split('=')
|
|
||||||
if (name && value) {
|
|
||||||
cookies[name.trim()] = decodeURIComponent(value.trim())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return cookies
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
get,
|
|
||||||
set,
|
|
||||||
remove
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -265,11 +265,9 @@ const form = ref({
|
|||||||
remark: ''
|
remark: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const cookie = useCookie()
|
|
||||||
const panEnables = ref(['quark'])
|
const panEnables = ref(['quark'])
|
||||||
const xunleiEnable = cookie.get('xunleiEnable')
|
const xunleiEnable = useCookie('xunleiEnable', { default: () => false })
|
||||||
console.log(xunleiEnable)
|
if (xunleiEnable.value && xunleiEnable.value === 'true') {
|
||||||
if (xunleiEnable && xunleiEnable === 'true') {
|
|
||||||
panEnables.value.push('xunlei')
|
panEnables.value.push('xunlei')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user