fix(bilibili/download): 付费内容下载前抛结构化 PAID_CONTENT#1947
Merged
jackwener merged 2 commits intoJun 15, 2026
Conversation
下游需要在抓视频流之前就知道「付费 / 会员内容拿不到流」。原来对会员 / 付费视频直接调 yt-dlp,跑一半吐一坨 stderr 才失败,下游难以判定到底是「付费拦截」还是「真的下载出错」。本 PR 在 download 入口加一道付费预检。 ## 行为 - 付费内容(view API 的 `rights.pay` 等付费标记)→ 在调 yt-dlp **之前**抛结构化 `CliError`(code `PAID_CONTENT`,exit 77),而非 yt-dlp stderr; - 大会员专享(`vip`)再查一次 `nav` API:当前账号大会员有效就**放行**(cookie 喂给 yt-dlp 能拿到流); - `--force` 跳过预检(已购买 / 已充电场景的逃生舱); - 预检自身的 API 失败**不阻塞**下载(保守,保持旧行为 —— 预检只做拦截增强,不引入新的失败面)。 ## 副作用边界 - 仅对**付费 / 会员**内容改变行为(从「yt-dlp 中途失败」变成「下载前结构化报错」);普通视频路径完全不变; - `--force` 让已购用户保留原下载能力,不会误伤; - 预检失败 fail-open(继续下载),所以最坏情况退回旧行为,不会因为预检本身挂掉而拦正常下载。 ## 测试 - 新增 `clis/bilibili/download.test.js`:付费内容拦截、vip 账号有效放行、`--force` 跳过预检、预检 API 失败不阻塞 - bilibili 全量适配器测试 93 通过;`tsc --noEmit` 干净;`check:silent-column-drop` new=0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
下游需要在抓视频流之前就知道「付费 / 会员内容拿不到流」。原来对会员 / 付费视频直接调 yt-dlp,跑一半吐一坨 stderr 才失败,下游难以判定到底是「付费拦截」还是「真的下载出错」。本 PR 在 download 入口加一道付费预检。
行为
rights.pay等付费标记)→ 在调 yt-dlp 之前抛结构化CliError(codePAID_CONTENT,exit 77),而非 yt-dlp stderr;vip)再查一次navAPI:当前账号大会员有效就放行(cookie 喂给 yt-dlp 能拿到流);--force:跳过预检(已购买 / 已充电 / 已开通会员场景的逃生舱);副作用边界(行为改动)
--force让已购用户保留原下载能力,不会误伤;测试
clis/bilibili/download.test.js:付费内容拦截、vip 账号有效放行、--force跳过预检、预检 API 失败不阻塞tsc --noEmit干净;check:silent-column-dropnew=0;manifest 已重新生成(新增--force参数声明)