stnh70 commited on
Commit
793fa96
·
verified ·
1 Parent(s): 420d15c

Update thunderapi/thunderapi.ts

Browse files
Files changed (1) hide show
  1. thunderapi/thunderapi.ts +42 -2
thunderapi/thunderapi.ts CHANGED
@@ -2520,7 +2520,7 @@ apiRouter.post("/get_share_folder", async (ctx) => {
2520
  if (!ensureClient(ctx)) return;
2521
 
2522
  try {
2523
- // 从查询参数中获取参数,而不是请求体
2524
  const url = new URL(ctx.request.url);
2525
  const shareId = url.searchParams.get("share_id");
2526
  const passCodeToken = url.searchParams.get("pass_code_token") || null;
@@ -2533,7 +2533,7 @@ apiRouter.post("/get_share_folder", async (ctx) => {
2533
  return;
2534
  }
2535
 
2536
- // 调用PikPak API
2537
  const result = await withCaptchaRetry(
2538
  "GET:/drive/v1/share/detail",
2539
  () => THUNDERX_CLIENT.getShareFolder(shareId, passCodeToken, parentId)
@@ -2547,6 +2547,46 @@ apiRouter.post("/get_share_folder", async (ctx) => {
2547
  }
2548
  });
2549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2550
  // 添加健康检查路由
2551
  apiRouter.get("/health", (ctx) => {
2552
  ctx.response.body = {
 
2520
  if (!ensureClient(ctx)) return;
2521
 
2522
  try {
2523
+ // 从查询参数中获取参数
2524
  const url = new URL(ctx.request.url);
2525
  const shareId = url.searchParams.get("share_id");
2526
  const passCodeToken = url.searchParams.get("pass_code_token") || null;
 
2533
  return;
2534
  }
2535
 
2536
+ // 调用PikPak API - 使用迅雷网盘链接格式
2537
  const result = await withCaptchaRetry(
2538
  "GET:/drive/v1/share/detail",
2539
  () => THUNDERX_CLIENT.getShareFolder(shareId, passCodeToken, parentId)
 
2547
  }
2548
  });
2549
 
2550
+ // 验证分享密码 - 获取pass_code_token
2551
+ apiRouter.post("/verify_share_password", async (ctx) => {
2552
+ if (!ensureClient(ctx)) return;
2553
+
2554
+ try {
2555
+ const requestBody = await ctx.request.body.json();
2556
+ const shareId = requestBody.share_id;
2557
+ const passCode = requestBody.pass_code;
2558
+
2559
+ if (!shareId || !passCode) {
2560
+ ctx.response.status = Status.BadRequest;
2561
+ ctx.response.body = { error: "share_id and pass_code are required" };
2562
+ return;
2563
+ }
2564
+
2565
+ // 构造分享链接 - 使用迅雷网盘的格式
2566
+ const shareLink = `https://pan.xunlei.com/s/${shareId}`;
2567
+
2568
+ // 调用验证密码的API
2569
+ const result = await withCaptchaRetry(
2570
+ "GET:/drive/v1/share",
2571
+ () => THUNDERX_CLIENT.getShareInfo(shareLink, passCode)
2572
+ );
2573
+
2574
+ // 如果成功,返回pass_code_token
2575
+ if (result && result.pass_code_token) {
2576
+ ctx.response.body = {
2577
+ pass_code_token: result.pass_code_token,
2578
+ success: true
2579
+ };
2580
+ } else {
2581
+ throw new Error("Failed to get pass_code_token");
2582
+ }
2583
+ } catch (error) {
2584
+ console.error("验证分享密码失败:", error);
2585
+ ctx.response.status = Status.InternalServerError;
2586
+ ctx.response.body = { error: error.message };
2587
+ }
2588
+ });
2589
+
2590
  // 添加健康检查路由
2591
  apiRouter.get("/health", (ctx) => {
2592
  ctx.response.body = {