UNPKG

rsshub

Version:
70 lines (68 loc) 2.26 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; //#region lib/routes/alipan/files.ts const route = { path: "/files/:share_id/:parent_file_id?", example: "/alipan/files/jjtKEgXJAtC/64a957744876479ab17941b29d1289c6ebdd71ef", parameters: { share_id: "分享 id,可以从分享页面 URL 中找到", parent_file_id: "文件夹 id,可以从文件夹页面 URL 中找到" }, radar: [{ source: ["www.alipan.com/s/:share_id/folder/:parent_file_id", "www.alipan.com/s/:share_id"] }], name: "文件列表", maintainers: ["DIYgod"], handler, url: "www.alipan.com/s" }; async function handler(ctx) { const { share_id, parent_file_id } = ctx.req.param(); const url = `https://www.aliyundrive.com/s/${share_id}${parent_file_id ? `/folder/${parent_file_id}` : ""}`; const headers = { referer: "https://www.aliyundrive.com/", origin: "https://www.aliyundrive.com", "x-canary": "client=web,app=share,version=v2.3.1" }; const shareRes = await ofetch_default("https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous", { method: "POST", headers, query: { share_id }, body: { share_id } }); const shareToken = (await ofetch_default("https://api.aliyundrive.com/v2/share_link/get_share_token", { method: "POST", headers, body: { share_id } })).share_token; const result = (await ofetch_default("https://api.aliyundrive.com/adrive/v2/file/list_by_share", { method: "POST", headers: { ...headers, "x-share-token": shareToken }, body: { limit: 100, order_by: "created_at", order_direction: "DESC", parent_file_id: parent_file_id || "root", share_id } })).items.map((item) => ({ title: item.name, description: item.name + (item.thumbnail ? `<img src="${item.thumbnail}">` : ""), link: url, pubDate: parseDate(item.created_at), updated: parseDate(item.updated_at), guid: item.file_id })); return { title: `${shareRes.display_name || `${share_id}${parent_file_id ? `-${parent_file_id}` : ""}`}-阿里云盘`, link: url, item: result }; } //#endregion export { route };