mirror of https://github.com/yutto-dev/yutto
🔨 ci: fix and integrate typos in CI (#276)
This commit is contained in:
parent
7054817168
commit
4606dc7a46
|
@ -100,7 +100,7 @@ poetry run yutto -v
|
|||
│ ├── parser.py # 文件解析器(解析任务列表、alias 文件)
|
||||
│ ├── path_resolver.py # 路径处理器(需处理路径变量)
|
||||
│ └── progressbar.py # 进度条(本部分可替换成为其他行为以支持更丰富的进度显示方式)
|
||||
├── utils # yutto 无关或弱相关模块,不应依赖 yutto 强相关模块(api、extrator、processor),含部分类型资源的基本封装(弹幕、字幕、描述文件)
|
||||
├── utils # yutto 无关或弱相关模块,不应依赖 yutto 强相关模块(api、extractor、processor),含部分类型资源的基本封装(弹幕、字幕、描述文件)
|
||||
│ ├── __init__.py
|
||||
│ ├── asynclib.py # 封装部分异步相关方法
|
||||
│ ├── console # 命令行打印相关
|
||||
|
@ -129,14 +129,14 @@ poetry run yutto -v
|
|||
1. 解析参数并利用 [yutto/validator.py](./yutto/validator.py) 验证参数的正确性,虽然 argparse 已经做了基本的验证,但 validator 会进一步的验证。另外目前 validator 还会顺带做全局状态的设置的工作,这部分以后可能修改。
|
||||
2. 利用 [yutto/processor/parser.py](./yutto/processor/parser.py) 解析 alias 和任务列表
|
||||
3. 遍历任务列表下载:
|
||||
1. 初始化提取器 [yutto/extrator/](./yutto/extractor/)
|
||||
1. 初始化提取器 [yutto/extractor/](./yutto/extractor/)
|
||||
2. 利用所有提取器处理 id 为可识别的 url
|
||||
3. 重定向一下入口 url 到可识别的 url
|
||||
4. 从入口 url 提取信息,构造解析任务
|
||||
1. 如果是单话下载(继承 `yutto.extrator._abc.SingleExtrator`)
|
||||
1. 如果是单话下载(继承 `yutto.extractor._abc.SingleExtractor`)
|
||||
1. 解析有用信息以提供给路径变量
|
||||
2. 使用 `yutto.extrator.common` 里的低阶提取器构造链接解析任务
|
||||
2. 如果是批量下载(继承 `yutto.extrator._abc.BatchExtrator`)
|
||||
2. 使用 `yutto.extractor.common` 里的低阶提取器构造链接解析任务
|
||||
2. 如果是批量下载(继承 `yutto.extractor._abc.BatchExtractor`)
|
||||
1. 循环解析列表
|
||||
2. 展平列表
|
||||
3. 选集(如果支持的话)
|
||||
|
|
|
@ -725,7 +725,7 @@ yutto 自诞生以来已经过去三年多了,功能上基本可以替代 bili
|
|||
- [x] refactor: 整理路径变量名
|
||||
- [x] feat: 视频合集选集支持(合集貌似有取代分 p 的趋势,需要对其进行合适的处理)
|
||||
- [ ] refactor: 针对视频合集优化路径变量
|
||||
- [ ] refactor: 优化杜比视界/音效/全景声选取逻辑(Disscusing in [#62](https://github.com/yutto-dev/yutto/discussions/62))
|
||||
- [ ] refactor: 优化杜比视界/音效/全景声选取逻辑(Discussing in [#62](https://github.com/yutto-dev/yutto/discussions/62))
|
||||
- [ ] docs: 可爱的静态文档(WIP in [#86](https://github.com/yutto-dev/yutto/pull/86))
|
||||
|
||||
### future
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[default.extend-identifiers]
|
||||
pn = "pn" # Abbr. for "page number"
|
1
justfile
1
justfile
|
@ -19,6 +19,7 @@ fmt:
|
|||
lint:
|
||||
poetry run pyright yutto tests
|
||||
poetry run ruff check .
|
||||
poetry run typos
|
||||
|
||||
build:
|
||||
touch yutto/py.typed
|
||||
|
|
|
@ -396,7 +396,26 @@ files = [
|
|||
{file = "typing_extensions-4.12.1.tar.gz", hash = "sha256:915f5e35ff76f56588223f15fdd5938f9a1cf9195c0de25130c627e4d597f6d1"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typos"
|
||||
version = "1.22.0"
|
||||
description = "Source Code Spelling Correction"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "typos-1.22.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:db9960b691aa9adcfac50af1edd890bd7667c3a40086469cf63a2f2a7b3674a9"},
|
||||
{file = "typos-1.22.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:b719933d92ff1abf9ce2b390424fa71bca3073b7e036c6c340461860395572de"},
|
||||
{file = "typos-1.22.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4a9baf8a52b19506bb598f9b3ad8ea3c33988ad61647bda613962f284721cd9f"},
|
||||
{file = "typos-1.22.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:733e7e311e512f80b058697b203168c7e90cd22aa235fbb43a75f1e1c1a9669e"},
|
||||
{file = "typos-1.22.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4d1b51417cd5b2300a9a3bf34eb4f3a03dce730eb928caacf0ed346658653e2"},
|
||||
{file = "typos-1.22.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:934d22bd0df0404e628e977387f8718b8dd5f60a910ecbfa4f96ee9d9e62e896"},
|
||||
{file = "typos-1.22.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a5d71d86cf3f6455f269fb5694b3548a09fba539312d0da9a15f4d9c4d0f3240"},
|
||||
{file = "typos-1.22.0-py3-none-win32.whl", hash = "sha256:4b3a3cb181136e7ddf0c0c2a2422fcb561407128c790cb89a7d39231ff77fcbd"},
|
||||
{file = "typos-1.22.0-py3-none-win_amd64.whl", hash = "sha256:3a27053b417cef148ab8d5f1a886f34b0d99f05cd4713476124424f598f6d91f"},
|
||||
{file = "typos-1.22.0.tar.gz", hash = "sha256:abe84d585cc6c20ef245a4d5fc0ac0689c8730551f5701833c90f70e07d9d3a5"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9.0"
|
||||
content-hash = "f8c32955b3633acb12d73dc360b50eb3d5c9aa6ba003b79c8934ee1c9abb1ad0"
|
||||
content-hash = "9832cc75c6dce8905af310df39b025d77bf003dbb61862ea003f14c6822f0a3c"
|
||||
|
|
|
@ -37,6 +37,7 @@ pytest = "^8.2.1"
|
|||
pyright = "1.1.364"
|
||||
pytest-rerunfailures = "^14.0"
|
||||
ruff = "^0.4.5"
|
||||
typos = "^1.22.0"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
yutto = "yutto.__main__:main"
|
||||
|
|
|
@ -42,7 +42,7 @@ from yutto.utils.time import TIME_DATE_FMT, TIME_FULL_FMT
|
|||
from yutto.validator import (
|
||||
initial_validation,
|
||||
validate_basic_arguments,
|
||||
validate_batch_argments,
|
||||
validate_batch_arguments,
|
||||
validate_user_info,
|
||||
)
|
||||
|
||||
|
@ -238,7 +238,7 @@ async def run(args_list: list[argparse.Namespace]):
|
|||
|
||||
# 验证批量参数
|
||||
if args.batch:
|
||||
validate_batch_argments(args)
|
||||
validate_batch_arguments(args)
|
||||
|
||||
# 初始化各种提取器
|
||||
extractors = (
|
||||
|
|
|
@ -81,7 +81,7 @@ def parse_episodes_selection(episodes_str: str, total: int) -> list[int]:
|
|||
Logger.warning("该剧集列表无任何剧集,猜测正片尚未上线,如果想要下载 PV 等特殊剧集,请添加参数 -s")
|
||||
return []
|
||||
|
||||
def resolve_negetive(value: int) -> int:
|
||||
def resolve_negative(value: int) -> int:
|
||||
if value == 0:
|
||||
Logger.error("不可使用 0 作为剧集号(剧集号从 1 开始计算)")
|
||||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
|
@ -94,21 +94,21 @@ def parse_episodes_selection(episodes_str: str, total: int) -> list[int]:
|
|||
episode_list: list[int] = []
|
||||
for episode_item in episodes_str.split(","):
|
||||
if "~" in episode_item:
|
||||
splitted = episode_item.split("~")
|
||||
if len(splitted) != 2:
|
||||
split_range = episode_item.split("~")
|
||||
if len(split_range) != 2:
|
||||
Logger.error(f"{episode_item} 选集参数每部分至多包含一个 ~")
|
||||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
start, end = splitted
|
||||
start, end = split_range
|
||||
start, end = "1" if not start else start, "-1" if not end else end
|
||||
start, end = int(start), int(end)
|
||||
start, end = resolve_negetive(start), resolve_negetive(end)
|
||||
start, end = resolve_negative(start), resolve_negative(end)
|
||||
if not (end >= start):
|
||||
Logger.error(f"终点值({end})应不小于起点值({start})")
|
||||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
episode_list.extend(list(range(start, end + 1)))
|
||||
else:
|
||||
episode_item = int(episode_item)
|
||||
episode_item = resolve_negetive(episode_item)
|
||||
episode_item = resolve_negative(episode_item)
|
||||
episode_list.append(episode_item)
|
||||
else:
|
||||
episode_list = []
|
||||
|
|
|
@ -124,7 +124,7 @@ class FFmpegOutput:
|
|||
selected_inputs = concat_commands([["-map", str(input.input_id)] for input in self.used_inputs])
|
||||
vcodec = ["-vcodec", self.vcodec] if self.vcodec else []
|
||||
acodec = ["-acodec", self.acodec] if self.acodec else []
|
||||
# Refer to `-disposition` opiton in https://www.ffmpeg.org/ffmpeg.html#toc-Main-options
|
||||
# Refer to `-disposition` option in https://www.ffmpeg.org/ffmpeg.html#toc-Main-options
|
||||
cover_options = (
|
||||
[
|
||||
f"-c:v:{self.cover_input.stream_id}",
|
||||
|
|
|
@ -88,11 +88,11 @@ def validate_basic_arguments(args: argparse.Namespace):
|
|||
)
|
||||
|
||||
# vcodec 检查
|
||||
vcodec_splited = args.vcodec.split(":")
|
||||
if len(vcodec_splited) != 2:
|
||||
vcodec_split = args.vcodec.split(":")
|
||||
if len(vcodec_split) != 2:
|
||||
Logger.error(f"vcodec 参数值({args.vcodec})不满足要求哦(并非使用 : 分隔的值)")
|
||||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
video_download_codec, video_save_codec = vcodec_splited
|
||||
video_download_codec, video_save_codec = vcodec_split
|
||||
if video_download_codec not in download_vcodec_priority:
|
||||
Logger.error(
|
||||
"download_vcodec 参数值({})不满足要求哦(允许值:{{{}}})".format(
|
||||
|
@ -113,11 +113,11 @@ def validate_basic_arguments(args: argparse.Namespace):
|
|||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
|
||||
# acodec 检查
|
||||
acodec_splited = args.acodec.split(":")
|
||||
if len(acodec_splited) != 2:
|
||||
acodec_split = args.acodec.split(":")
|
||||
if len(acodec_split) != 2:
|
||||
Logger.error(f"acodec 参数值({args.acodec})不满足要求哦(并非使用 : 分隔的值)")
|
||||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
audio_download_codec, audio_save_codec = acodec_splited
|
||||
audio_download_codec, audio_save_codec = acodec_split
|
||||
if audio_download_codec not in audio_codec_priority_default:
|
||||
Logger.error(
|
||||
"download_acodec 参数值({})不满足要求哦(允许值:{{{}}})".format(
|
||||
|
@ -134,7 +134,7 @@ def validate_basic_arguments(args: argparse.Namespace):
|
|||
sys.exit(ErrorCode.WRONG_ARGUMENT_ERROR.value)
|
||||
|
||||
|
||||
def validate_batch_argments(args: argparse.Namespace):
|
||||
def validate_batch_arguments(args: argparse.Namespace):
|
||||
"""检查批量下载相关选项"""
|
||||
# 检查 episodes 格式(简单的正则检查,后续过滤剧集时还有完整检查)
|
||||
if not validate_episodes_selection(args.episodes):
|
||||
|
|
Loading…
Reference in New Issue