Skip to content

Commit

Permalink
✨ feat: support 「智能修复」 video quality support (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Sep 11, 2024
1 parent 284ed95 commit 742207b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ yutto 支持一些基础参数,无论是批量下载还是单视频下载都
#### 指定视频清晰度等级

- 参数 `-q``--video-quality`
- 可选值 `127 | 126 | 125 | 120 | 116 | 112 | 80 | 74 | 64 | 32 | 16`
- 可选值 `127 | 126 | 125 | 120 | 116 | 112 | 100 | 80 | 74 | 64 | 32 | 16`
- 默认值 `127`

清晰度对应关系如下
Expand All @@ -169,13 +169,14 @@ yutto 支持一些基础参数,无论是批量下载还是单视频下载都
| 120 | 4K 超清 |
| 116 | 1080P 60帧 |
| 112 | 1080P 高码率 |
| 100 | 智能修复 |
| 80 | 1080P 高清 |
| 74 | 720P 60帧 |
| 64 | 720P 高清 |
| 32 | 480P 清晰 |
| 16 | 360P 流畅 |

并不是说指定某个清晰度就一定会下载该清晰度的视频,yutto 只会尽可能满足你的要求,如果不存在指定的清晰度,yutto 就会按照默认的清晰度搜索机制进行调节,比如指定清晰度为 `80`**首先会依次降清晰度搜索** `74``64``32``16`,如果依然找不到合适的则**继续升清晰度搜索** `112``116``120``125``126``127`
并不是说指定某个清晰度就一定会下载该清晰度的视频,yutto 只会尽可能满足你的要求,如果不存在指定的清晰度,yutto 就会按照默认的清晰度搜索机制进行调节,比如指定清晰度为 `80`**首先会依次降清晰度搜索** `74``64``32``16`,如果依然找不到合适的则**继续升清晰度搜索** `100``112``116``120``125``126``127`

值得注意的是,目前杜比视界视频只能简单下载音视频流并合并,合并后并不能达到在线观看的效果。

Expand Down
2 changes: 1 addition & 1 deletion src/yutto/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def cli() -> argparse.ArgumentParser:
default=127,
choices=video_quality_priority_default,
type=int,
help="视频清晰度等级(127:8K, 126:Dolby Vision, 125:HDR, 120:4K, 116:1080P60, 112:1080P+, 80:1080P, 74:720P60, 64:720P, 32:480P, 16:360P)",
help="视频清晰度等级(127:8K, 126:Dolby Vision, 125:HDR, 120:4K, 116:1080P60, 112:1080P+, 100:智能修复, 80:1080P, 74:720P60, 64:720P, 32:480P, 16:360P)",
)
group_common.add_argument(
"-aq",
Expand Down
2 changes: 1 addition & 1 deletion src/yutto/api/bangumi.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def get_bangumi_list(client: AsyncClient, season_id: SeasonId) -> BangumiL
async def get_bangumi_playurl(
client: AsyncClient, avid: AvId, cid: CId
) -> tuple[list[VideoUrlMeta], list[AudioUrlMeta]]:
play_api = "https://api.bilibili.com/pgc/player/web/v2/playurl?avid={aid}&bvid={bvid}&cid={cid}&qn=127&fnver=0&fnval=4048&fourk=1"
play_api = "https://api.bilibili.com/pgc/player/web/v2/playurl?avid={aid}&bvid={bvid}&cid={cid}&qn=127&fnver=0&fnval=4048&fourk=1&support_multi_audio=true&from_client=BROWSER"

resp_json = await Fetcher.fetch_json(client, play_api.format(**avid.to_dict(), cid=cid))
if resp_json is None:
Expand Down
9 changes: 7 additions & 2 deletions src/yutto/bilibili_typing/quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Media(Enum):
AUDIO = 30200


VideoQuality = Literal[127, 126, 125, 120, 116, 112, 80, 74, 64, 32, 16]
VideoQuality = Literal[127, 126, 125, 120, 116, 112, 100, 80, 74, 64, 32, 16]
AudioQuality = Literal[30251, 30255, 30250, 30280, 30232, 30216]

video_quality_priority_default: list[VideoQuality] = [127, 126, 125, 120, 116, 112, 80, 74, 64, 32, 16]
video_quality_priority_default: list[VideoQuality] = [127, 126, 125, 120, 116, 112, 100, 80, 74, 64, 32, 16]
audio_quality_priority_default: list[AudioQuality] = [30251, 30255, 30250, 30280, 30232, 30216]

video_quality_map = {
Expand Down Expand Up @@ -48,6 +48,11 @@ class Media(Enum):
"width": 1920,
"height": 1080,
},
100: {
"description": "智能修复",
"width": 1440,
"height": 1080,
}, # Example: ep327108
80: {
"description": "1080P 高清",
"width": 1920,
Expand Down

0 comments on commit 742207b

Please sign in to comment.