Skip to content

Commit

Permalink
✨ feat!: change default audio output format to m4a (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Dec 15, 2024
1 parent a47836c commit fa475ce
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dmypy.json
.DS_Store

# Media files
*.m4a
*.aac
*.mp3
*.flac
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ https://github.com/orgs/community/discussions/16925#discussioncomment-7571187
#### 指定在仅包含音频流时的输出格式

- 参数 `--output-format-audio-only`
- 可选值 `"infer" | "aac" | "mp3" | "flac" | "mp4" | "mkv" | "mov"`
- 可选值 `"infer" | "m4a" | "aac" | "mp3" | "flac" | "mp4" | "mkv" | "mov"`
- 默认值 `"infer"`

在仅包含音频流时所使用的输出格式,默认选值 `"infer"` 表示自动根据情况进行推导以保证输出的可用,推导规则如下:

- 如果音频流编码为 `"fLaC"`,则输出格式为 `"flac"`
- 否则为 `"aac"`
- 否则为 `"m4a"`

> **Note**
>
Expand Down Expand Up @@ -464,7 +464,7 @@ cat ~/.yutto_alias | yutto tensura-nikki --batch --alias-file -
- 参数 `--audio-only`
- 默认值 `False`

仅下载其中的音频流,保存为 `.aac` 文件。
仅下载其中的音频流,保存为 `.m4a` 文件。

#### 不生成弹幕文件

Expand Down
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ clean:
-e mp4 \
-e mkv \
-e mov \
-e m4a \
-e aac \
-e mp3 \
-e flac \
Expand Down
1 change: 1 addition & 0 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"default": "infer",
"enum": [
"infer",
"m4a",
"aac",
"mp3",
"flac",
Expand Down
2 changes: 1 addition & 1 deletion src/yutto/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def cli() -> argparse.ArgumentParser:
group_basic.add_argument(
"--output-format-audio-only",
default=settings.basic.output_format_audio_only,
choices=["infer", "aac", "mp3", "flac", "mp4", "mkv", "mov"],
choices=["infer", "m4a", "aac", "mp3", "flac", "mp4", "mkv", "mov"],
help="仅包含音频流时所使用的输出格式(infer 为自动推断)",
)
group_basic.add_argument(
Expand Down
4 changes: 3 additions & 1 deletion src/yutto/cli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class YuttoBasicSettings(BaseModel):
acodec: Annotated[str, Field("mp4a:copy")]
download_vcodec_priority: Annotated[Optional[list[str]], Field(None)] # noqa: UP007
output_format: Annotated[Literal["infer", "mp4", "mkv", "mov"], Field("infer")]
output_format_audio_only: Annotated[Literal["infer", "aac", "mp3", "flac", "mp4", "mkv", "mov"], Field("infer")]
output_format_audio_only: Annotated[
Literal["infer", "m4a", "aac", "mp3", "flac", "mp4", "mkv", "mov"], Field("infer")
]
danmaku_format: Annotated[Literal["xml", "ass", "protobuf"], Field("ass")]
block_size: Annotated[float, Field(0.5)]
overwrite: Annotated[bool, Field(False)]
Expand Down
2 changes: 1 addition & 1 deletion src/yutto/processor/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ async def start_downloader(
elif will_download_audio and audio["codec"] == "flac": # pyright: ignore [reportOptionalSubscript]
output_format = ".flac"
else:
output_format = ".aac"
output_format = ".m4a"
else:
if options["output_format"] != "infer":
output_format = "." + options["output_format"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_biliass/test_corpus
Submodule test_corpus updated 1 files
+1 −0 .gitignore
75 changes: 50 additions & 25 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa475ce

Please sign in to comment.