Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add conf to edit the config #8

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
python -m biliarchiver.cli_tools.biliarchiver down --help
python -m biliarchiver.cli_tools.biliarchiver get --help
python -m biliarchiver.cli_tools.biliarchiver up --help
python -m biliarchiver.cli_tools.biliarchiver config --help
# - name: Test with pytest
# run: |
# pytest
2 changes: 2 additions & 0 deletions biliarchiver/cli_tools/biliarchiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from biliarchiver.cli_tools.up_command import up
from biliarchiver.cli_tools.down_command import down
from biliarchiver.cli_tools.get_command import get
from biliarchiver.cli_tools.conf_command import config
from biliarchiver.version import BILI_ARCHIVER_VERSION


Expand Down Expand Up @@ -58,6 +59,7 @@ def init():
biliarchiver.add_command(up)
biliarchiver.add_command(down)
biliarchiver.add_command(get)
biliarchiver.add_command(config)


@biliarchiver.command(help=click.style(_("配置账号信息"), fg="cyan"))
Expand Down
20 changes: 20 additions & 0 deletions biliarchiver/cli_tools/conf_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import click
from dataclasses import dataclass
from biliarchiver.i18n import _

@click.command(help=click.style(_("将传入参数写入配置文件"), fg="cyan"))
@click.option("--video_concurrency", "-v", type=click.INT, default=None, help=_("视频下载并发数"))
@click.option("--part_concurrency", "-p", type=click.INT, default=None, help=_("分P下载并发数"))
@click.option("--stream_retry", "-r", type=click.INT, default=None, help=_("流下载重试次数"))
@click.option("--storage_home_dir", "-s", type=click.STRING, default=None, help=_("存储目录"))
@click.option("--ia_key_file", "-i", type=click.STRING, default=None, help=_("IA key文件"))
@click.option("--cookies_file", "-c", type=click.STRING, default=None, help=_("cookies文件"))

def config(**kwargs):
from biliarchiver.config import _Config
config = _Config()
for k, v in kwargs.items():
if v is not None:
setattr(config, k, v)
config.save()
print(_("配置文件写入成功"))
32 changes: 32 additions & 0 deletions biliarchiver/locales/biliarchiver.pot
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,38 @@ msgstr ""
msgid "已废弃直接运行此命令,请改用 biliarchiver 命令"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:6
msgid "将传入参数写入配置文件"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:7
msgid "视频下载并发数"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:8
msgid "分P下载并发数"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:9
msgid "流下载重试次数"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:10
msgid "存储目录"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:11
msgid "IA key文件"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:12
msgid "cookies文件"
msgstr ""

#: biliarchiver/cli_tools/conf_command.py:20
msgid "配置文件写入成功"
msgstr ""

#: biliarchiver/cli_tools/down_command.py:6
msgid "从哔哩哔哩下载"
msgstr ""
Expand Down
32 changes: 32 additions & 0 deletions biliarchiver/locales/en/LC_MESSAGES/biliarchiver.po
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,38 @@ msgstr "Not logged in, or SESSDATA invalid/expired. Your cookies seems to have e
msgid "已废弃直接运行此命令,请改用 biliarchiver 命令"
msgstr "This command is deprecated. Use `biliarchiver down` instead."

#: biliarchiver/cli_tools/conf_command.py:6
msgid "将传入参数写入配置文件"
msgstr "Write the passed parameters to the configuration file"

#: biliarchiver/cli_tools/conf_command.py:7
msgid "视频下载并发数"
msgstr "Video download concurrency"

#: biliarchiver/cli_tools/conf_command.py:8
msgid "分P下载并发数"
msgstr "Part download concurrency"

#: biliarchiver/cli_tools/conf_command.py:9
msgid "流下载重试次数"
msgstr "Stream download retry count"

#: biliarchiver/cli_tools/conf_command.py:10
msgid "存储目录"
msgstr "Storage home directory"

#: biliarchiver/cli_tools/conf_command.py:11
msgid "IA key文件"
msgstr "IA key file"

#: biliarchiver/cli_tools/conf_command.py:12
msgid "cookies文件"
msgstr "Cookies file"

#: biliarchiver/cli_tools/conf_command.py:20
msgid "配置文件写入成功"
msgstr "Configuration file written successfully"

#: biliarchiver/cli_tools/down_command.py:6
msgid "从哔哩哔哩下载"
msgstr "Download from BiliBili"
Expand Down