From 742207ba716800dec3bbd347b105245084142523 Mon Sep 17 00:00:00 2001 From: Nyakku Shigure Date: Thu, 12 Sep 2024 03:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20support=20=E3=80=8C?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E4=BF=AE=E5=A4=8D=E3=80=8D=20video=20quality?= =?UTF-8?q?=20support=20(#302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++-- src/yutto/__main__.py | 2 +- src/yutto/api/bangumi.py | 2 +- src/yutto/bilibili_typing/quality.py | 9 +++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7e43a61af..276a8aef1 100644 --- a/README.md +++ b/README.md @@ -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` 清晰度对应关系如下 @@ -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`。 值得注意的是,目前杜比视界视频只能简单下载音视频流并合并,合并后并不能达到在线观看的效果。 diff --git a/src/yutto/__main__.py b/src/yutto/__main__.py index 2709030fc..371a5de92 100644 --- a/src/yutto/__main__.py +++ b/src/yutto/__main__.py @@ -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", diff --git a/src/yutto/api/bangumi.py b/src/yutto/api/bangumi.py index fa00e3a2d..1ebd9009c 100644 --- a/src/yutto/api/bangumi.py +++ b/src/yutto/api/bangumi.py @@ -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: diff --git a/src/yutto/bilibili_typing/quality.py b/src/yutto/bilibili_typing/quality.py index 2bdc16d96..5f63128d7 100644 --- a/src/yutto/bilibili_typing/quality.py +++ b/src/yutto/bilibili_typing/quality.py @@ -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 = { @@ -48,6 +48,11 @@ class Media(Enum): "width": 1920, "height": 1080, }, + 100: { + "description": "智能修复", + "width": 1440, + "height": 1080, + }, # Example: ep327108 80: { "description": "1080P 高清", "width": 1920,