一分钟搭建影视站,支持Docker等部署方式
feat(subscription): 订阅源标识与同步边界保护,同步改为纯手动
bestZwei5b54d59e1e69
diff --git a/.gitignore b/.gitignoreindex e8bee2a..d0ef08c 100644--- a/.gitignore+++ b/.gitignore@@ -6,3 +6,4 @@ out/vitest-results.json*.log.mimosa/+.zcode/\ No newline at end of filediff --git a/docs/Configuration.md b/docs/Configuration.mdindex c20639f..5983f67 100644--- a/docs/Configuration.md+++ b/docs/Configuration.md@@ -36,7 +36,8 @@ DEFAULT_SOURCES=[{"name":"示例源","url":"https://example.com/api.php/provide/### 数据源- **自定义 API 列表**:名称、API 地址、详情页地址(可选)、成人标记;-- **勾选参与搜索的源**:仅勾选的源会参与聚合搜索与换源。+- **勾选参与搜索的源**:仅勾选的源会参与聚合搜索与换源;+- **源订阅**:远程源列表地址与上次同步时间,格式与行为见 [Data-Sources · 源订阅](Data-Sources.md#源订阅--分享)。同步为手动操作(订阅条目 **⟳**),远端列表更新后需手动刷新。### 播放与过滤diff --git a/docs/Data-Sources.md b/docs/Data-Sources.mdindex 6796750..4a09fc3 100644--- a/docs/Data-Sources.md+++ b/docs/Data-Sources.md@@ -53,28 +53,53 @@ Apple CMS(苹果CMS)标准采集接口,即提供以下接口的资源站## 源订阅 / 分享-源列表可以脱离单台设备流转:+源列表可以脱离单台设备流转:导出为 JSON 文件 → 托管到任意公开 URL → 他人在「设置」里填入该 URL 订阅。-**分享(导出)**:设置 → 源订阅 / 分享 → 「导出源列表」,生成如下格式的 JSON 文件:+### 订阅格式(LibreTV-SourceList JSON)```json{- "name": "LibreTV-SourceList",+ "name": "我的源列表","version": 1,"sources": [- { "name": "暴风资源", "url": "https://bfzyapi.com/api.php/provide/vod", "detail": "", "isAdult": false }+ {+ "name": "暴风资源",+ "url": "https://bfzyapi.com/api.php/provide/vod",+ "detail": "https://bfzyapi.com",+ "isAdult": false+ }]}```-把文件托管到任意可公开访问的 URL(Gist、对象存储、自建静态服务均可),该 URL 就是一个「订阅地址」。也接受裸数组格式 `[{name,url,...}, ...]`。+**字段说明**:-**订阅(导入)**:设置 → 源订阅 / 分享 → 填入订阅地址 → 「订阅」:+| 字段 | 位置 | 类型 | 必填 | 说明 |+| --- | --- | --- | --- | --- |+| `name` | 顶层 | string | 否 | 列表名称,订阅后显示在订阅条目上;缺省时显示订阅地址主机名 |+| `version` | 顶层 | number | 否 | 格式版本,当前为 `1`;导入端目前忽略该字段 |+| `sources` | 顶层 | array | **是** | 源数组,最多 100 个,超出部分截断 |+| `sources[].name` | 项 | string | 否 | 源显示名;缺省时使用 URL 主机名 |+| `sources[].url` | 项 | string | **是** | Apple CMS 采集接口地址(公网 http/https),结尾 `/` 自动去除 |+| `sources[].detail` | 项 | string | 否 | 详情页根地址,用于列表接口拿不到播放地址的源 |+| `sources[].isAdult` | 项 | boolean | 否 | 成人内容标记,默认 `false`;受「成人内容过滤」开关控制 |-- 服务端拉取并校验 JSON(协议白名单 + 内网地址过滤,单列表上限 100 个源,按 URL 去重);-- 导入的源以 `sub_` 前缀 key 管理,自动勾选(成人过滤开启时跳过成人源);-- 远端列表更新后点 **⟳** 重新同步(整体替换该订阅名下的源,与订阅 URL 相同的手动源会被去重合并);-- 删除订阅会同时移除其导入的所有源。+**兼容与限制**:++- 也接受**裸数组**格式 `[{ "name": "...", "url": "..." }, ...]`(此时列表名显示为主机名);+- 按 `url` 去重(先到先得);非公网 http(s) 地址(内网/回环/保留地址)会被**静默过滤**;+- 订阅由**服务端**拉取(拉取前经过 SSRF 校验),因此订阅地址**无需配置 CORS**,Gist、对象存储、任意静态托管均可。++### 订阅行为++- **导入**:设置 → 源订阅 / 分享 → 填入订阅地址 → 「订阅」;导入的源自动勾选(成人过滤开启时跳过成人源),并在列表中带「订阅」标识;+- **手动同步**:订阅条目上的 **⟳** 随时强制同步——整体替换该订阅名下的源(与订阅 URL 相同的手动源会被去重合并),成功/失败均以提示反馈;+- **订阅源的管理边界**:订阅源以远端列表为准——单独编辑会在下次同步时被覆盖,单独移除会在重新同步时恢复;如需调整请修改远端列表后同步,或直接删除整个订阅;+- **删除订阅**:同时移除其导入的所有源。++### 分享(导出)++设置 → 源订阅 / 分享 → 「导出源列表」:把当前全部来源(部署者预置 + 手动添加 + 订阅导入,按 URL 去重)导出为上述格式的 JSON 文件。托管后即可被他人订阅。## 自定义源的数据流diff --git a/package.json b/package.jsonindex c17ebd6..88d435d 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "libretv-next",- "version": "2.2.1",+ "version": "2.2.2","private": true,"description": "免费在线视频搜索与观看平台(Next.js 重构版)","license": "AGPL-3.0-or-later",diff --git a/src/components/source-manager.tsx b/src/components/source-manager.tsxindex c3de7e6..0504694 100644--- a/src/components/source-manager.tsx+++ b/src/components/source-manager.tsx@@ -19,6 +19,7 @@ type TestState =export function SourceManagerDrawer({ open, onClose }: { open: boolean; onClose: () => void }) {const store = useAppStore();+ const { toast } = useToast();const [editing, setEditing] = useState<string | null>(null);const [tests, setTests] = useState<Record<string, TestState>>({});@@ -128,7 +129,9 @@ export function SourceManagerDrawer({ open, onClose }: { open: boolean; onClose:</ul>)}<ul className="space-y-2">- {store.customAPIs.map((api) => (+ {store.customAPIs.map((api) => {+ const fromSubscription = api.key.startsWith('sub_');+ return (<li key={api.key} className="bg-card rounded-lg p-3 transition-colors hover:bg-hover/50">{editing === api.key ? (<SourceForm@@ -158,28 +161,64 @@ export function SourceManagerDrawer({ open, onClose }: { open: boolean; onClose:{api.isAdult && store.yellowFilter && (<span className="text-[10px] text-faint ml-1">过滤开启中,需关闭后才能启用</span>)}+ {fromSubscription && (+ <span+ className="ml-1.5 text-[10px] px-1.5 py-0.5 rounded bg-accent/10 text-accent align-middle"+ title="来自源订阅,重新同步时此源的名称/地址会以订阅内容为准"+ >+ 订阅+ </span>+ )}</div><div className="text-xs text-faint truncate">{api.url}</div></div>{testButton(api.key, api.url)}- <button- className="rounded-md p-1.5 text-muted transition-colors hover:bg-hover hover:text-accent"- onClick={() => setEditing(api.key)}- aria-label="编辑"- >- ✎- </button>- <button- className="rounded-md p-1.5 text-muted transition-colors hover:bg-hover hover:text-red-400"- onClick={() => store.removeCustomApi(api.key)}- aria-label="删除"- >- ✕- </button>+ {fromSubscription ? (+ // 订阅源由远端列表管理:编辑会被下次同步覆盖,删除会复活,引导到订阅区操作+ <>+ <button+ className="rounded-md p-1.5 text-muted/40"+ aria-label="订阅源不可单独编辑"+ title="该源来自订阅,编辑修改会在下次同步时被覆盖;如需调整请修改远端订阅列表后重新同步"+ onClick={() => toast('订阅源以远端列表为准;请修改远端订阅内容后重新同步', 'info')}+ >+ ✎+ </button>+ <button+ className="rounded-md p-1.5 text-muted transition-colors hover:bg-hover hover:text-red-400"+ onClick={() => {+ store.removeCustomApi(api.key);+ toast('已移除;注意:重新同步订阅时该源会恢复', 'info');+ }}+ aria-label="删除"+ title="移除此源(重新同步订阅时会恢复)"+ >+ ✕+ </button>+ </>+ ) : (+ <>+ <button+ className="rounded-md p-1.5 text-muted transition-colors hover:bg-hover hover:text-accent"+ onClick={() => setEditing(api.key)}+ aria-label="编辑"+ >+ ✎+ </button>+ <button+ className="rounded-md p-1.5 text-muted transition-colors hover:bg-hover hover:text-red-400"+ onClick={() => store.removeCustomApi(api.key)}+ aria-label="删除"+ >+ ✕+ </button>+ </>+ )}</div>)}</li>- ))}+ );+ })}</ul></>)}