From 52905f8bdc2d60a6686c53684907a9387af7a0b5 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Sun, 22 Mar 2026 16:31:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E7=BA=BF=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SOURCE_SCRIPT.md | 20 +++++---- src/app/admin/page.tsx | 3 +- src/app/api/source-script/play/route.ts | 4 +- src/lib/source-script.ts | 59 ++++++++++++------------- 4 files changed, 42 insertions(+), 44 deletions(-) diff --git a/SOURCE_SCRIPT.md b/SOURCE_SCRIPT.md index 2873e7b..aefab62 100644 --- a/SOURCE_SCRIPT.md +++ b/SOURCE_SCRIPT.md @@ -42,8 +42,6 @@ return { { sourceId, sourceName: '默认源', - lineId: 'default', - lineName: '默认线路', episodes: [], episodes_titles: [] } @@ -51,7 +49,7 @@ return { }; }, - async resolvePlayUrl(ctx, { playUrl, sourceId, lineId, episodeIndex }) { + async resolvePlayUrl(ctx, { playUrl, sourceId, episodeIndex }) { return { url: playUrl, type: 'auto', @@ -71,7 +69,7 @@ return { 推荐 4. `detail({ id, sourceId })` 详情 -5. `resolvePlayUrl({ playUrl, sourceId, lineId, episodeIndex })` +5. `resolvePlayUrl({ playUrl, sourceId, episodeIndex })` 播放前解析最终地址 ## `ctx` 里能用什么 @@ -128,11 +126,12 @@ return { { sourceId: 'default', sourceName: '默认源', - lineId: 'line1', - lineName: '线路1', episodes: [ 'https://example.com/play/1', - 'https://example.com/play/2' + { + playUrl: 'https://example.com/play/2', + needResolve: false + } ], episodes_titles: ['第1集', '第2集'] } @@ -140,6 +139,12 @@ return { } ``` +说明: + +- `episodes` 可以是字符串,默认等价于 `{ playUrl: '...', needResolve: true }` +- `needResolve` 默认为 `true` +- 显式写 `needResolve: false` 时,播放页会直接使用该地址,不再调用 `resolvePlayUrl` + ## `resolvePlayUrl` 返回格式 ```js @@ -196,4 +201,3 @@ async resolvePlayUrl(ctx, { playUrl }) { "code": "return { ... }" } ``` - diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index b37889c..ce4d703 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -6278,7 +6278,6 @@ const VideoSourceScriptLab = () => { : JSON.stringify( { sourceId: 'main', - lineId: 'default', playUrl: 'https://example.com/video.m3u8', episodeIndex: 0, }, @@ -6469,7 +6468,7 @@ const VideoSourceScriptLab = () => {

- 现在脚本可以自己管理多个源和线路,测试入参可传 `sourceId`、`lineId`。 + 现在脚本可以自己管理多个源,测试入参可传 `sourceId`。