diff --git a/docs/multimedia.md b/docs/multimedia.md index 836e2fe9f..d24353617 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1181,6 +1181,12 @@ JavDB 有多个备用域名,本路由默认使用永久域名 +## 阿里云盘 + +### 文件列表 + + + ## 爱奇艺 ### 用户视频 diff --git a/lib/v2/aliyundrive/files.js b/lib/v2/aliyundrive/files.js new file mode 100644 index 000000000..bde4d11de --- /dev/null +++ b/lib/v2/aliyundrive/files.js @@ -0,0 +1,63 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const { share_id, parent_file_id } = ctx.params; + const url = `https://www.aliyundrive.com/s/${share_id}${parent_file_id ? `/folder/${parent_file_id}` : ''}`; + + const shareRes = await got.post('https://api.aliyundrive.com/adrive/v3/share_link/get_share_by_anonymous', { + params: { + share_id, + }, + json: { + share_id, + }, + headers: { + referer: 'https://www.aliyundrive.com/', + origin: 'https://www.aliyundrive.com', + 'x-canary': 'client=web,app=share,version=v2.3.1', + }, + }); + + const tokenRes = await got.post('https://api.aliyundrive.com/v2/share_link/get_share_token', { + headers: { + referer: 'https://www.aliyundrive.com/', + origin: 'https://www.aliyundrive.com', + 'x-canary': 'client=web,app=share,version=v2.3.1', + }, + json: { + share_id, + }, + }); + const share_token = tokenRes.data.share_token; + + const listRes = await got.post('https://api.aliyundrive.com/v2/file/list', { + headers: { + referer: 'https://www.aliyundrive.com/', + origin: 'https://www.aliyundrive.com', + 'x-canary': 'client=web,app=share,version=v2.3.1', + 'x-share-token': share_token, + }, + json: { + limit: 100, + order_by: 'created_at', + order_direction: 'DESC', + parent_file_id: parent_file_id || 'root', + share_id, + }, + }); + + const result = listRes.data.items.map((item) => ({ + title: item.name, + description: item.name + (item.thumbnail ? `` : ''), + link: url, + pubDate: item.created_at, + updated: item.updated_at, + guid: item.file_id, + })); + + ctx.state.data = { + title: `${shareRes.data.display_name || `${share_id}${parent_file_id ? `-${parent_file_id}` : ''}`}-阿里云盘`, + link: url, + item: result, + }; +}; diff --git a/lib/v2/aliyundrive/maintainer.js b/lib/v2/aliyundrive/maintainer.js new file mode 100644 index 000000000..c412a619a --- /dev/null +++ b/lib/v2/aliyundrive/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/files/:share_id/:parent_file_id?': ['DIYgod'], +}; diff --git a/lib/v2/aliyundrive/radar.js b/lib/v2/aliyundrive/radar.js new file mode 100644 index 000000000..56a538961 --- /dev/null +++ b/lib/v2/aliyundrive/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'aliyundrive.com': { + _name: '阿里云盘', + www: [ + { + title: '文件列表', + docs: 'https://docs.rsshub.app/programming.html#a-li-yun-pan', + source: ['/s/:share_id', '/s/:share_id/folder/:parent_file_id'], + target: '/aliyundrive/files/:share_id/:parent_file_id?', + }, + ], + }, +}; diff --git a/lib/v2/aliyundrive/router.js b/lib/v2/aliyundrive/router.js new file mode 100644 index 000000000..faa28adf4 --- /dev/null +++ b/lib/v2/aliyundrive/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/files/:share_id/:parent_file_id?', require('./files')); +};