Skip to content

Commit

Permalink
Merge branch 'devel' into pure-py
Browse files Browse the repository at this point in the history
# Conflicts:
#	ktoolbox/editor.py
  • Loading branch information
Ljzd-PRO committed Oct 26, 2024
2 parents 174db0f + e3cc7f5 commit f6e535f
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ Goto [Shortcuts for iOS](https://ktoolbox.readthedocs.io/latest/shortcut/) page

Goto [Configuration-Guide](https://ktoolbox.readthedocs.io/latest/configuration/guide/) page for more details.

![KToolBox Configuration Editor](static/preview-2.png)
![KToolBox Configuration Editor](static/preview-3.png)
![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png)
![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png)

## Other Branches

Expand Down
4 changes: 2 additions & 2 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ ktoolbox sync-creator https://kemono.su/fanbox/user/9016 --start-time=2024-1-1 -

前往 [配置-向导](https://ktoolbox.readthedocs.io/latest/zh/configuration/guide/) 页面查看更多详情。

![KToolBox 配置编辑器](static/preview-2.png)
![KToolBox 配置编辑器](static/preview-3.png)
![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png)
![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png)

## 其他分支

Expand Down
19 changes: 14 additions & 5 deletions docs/en/configuration/guide.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Guide

!!! tip "Graphical Configuration Editor"
Run `ktoolbox config-editor` to launch,
it will make configuration editing simple and convenient.

=== "Usage"

Run `ktoolbox config-editor` to launch,
it will make configuration editing simple and convenient.

- Press `<Esc>` for back, `<Enter>` for select
- You can also use the GUI with the mouse

=== "Screenshot"

![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png){ loading=lazy }
![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png){ loading=lazy }

!!! tip "Generate Example `.env` File"
Run `ktoolbox example-env` to generate a complete sample configuration file.

![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png)
![KToolBox Configuration Editor](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png)
Run `ktoolbox example-env` to generate a complete sample configuration file.

- KToolBox load **`.env` or `prod.env` file** in the **working directory** or **environment variables** to store configuration
- Check [Reference](reference.md) for all configuration options
Expand Down
69 changes: 68 additions & 1 deletion docs/en/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,71 @@ KTOOLBOX_JOB__SEQUENTIAL_FILENAME=True
# Set the post directory name to its release/publish date and ID, e.g. `[2024-1-1]11223344`
KTOOLBOX_JOB__POST_DIRNAME_FORMAT=[{published}]{id}
```
```

## How to Configure a Proxy?

You can set the `HTTPS_PROXY`, `HTTP_PROXY`, and `ALL_PROXY` environment variables to achieve this.

Refer to: [HTTPX - Environment Variables](https://www.python-httpx.org/environment_variables/#http_proxy-https_proxy-all_proxy)

For example, set it like this:

```shell
# Unix Shell
export HTTPS_PROXY=http://127.0.0.1:7897
export HTTP_PROXY=http://127.0.0.1:7897
export ALL_PROXY=socks5://127.0.0.1:7897
```

```powershell
# Windows PowerShell
$env:HTTP_PROXY="http://127.0.0.1:7897"; $env:HTTPS_PROXY="http://127.0.0.1:7897"
```

## GUI Configuration Editor Cannot Be Opened

!!! warning "Note"
[`ktoolbox-pure-py`](https://pypi.org/project/ktoolbox-pure-py/) does not support the graphical configuration editor.

By default, the dependencies for the graphical configuration editor are not installed. You can install them using the following command:

```shell
pip3 install ktoolbox[urwid]
```

If you are using pipx:

```shell
pipx install ktoolbox[urwid] --force
```

## Kemono API Call Failed

For example:

```
ktoolbox sync-creator "https://coomer.su/onlyfans/user/hollyharper11" --start-time="2020-05-01" --end-time="2025-01-01"
2024-05-12 12:52:51.477 | INFO | ktoolbox.cli:sync_creator:271 - Got creator information - {'name': 'hollyharper11', 'id': 'hollyharper11'}
2024-05-12 12:52:51.479 | INFO | ktoolbox.action.job:create_job_from_creator:148 - Start fetching posts from creator hollyharper11
2024-05-12 12:52:56.477 | ERROR | ktoolbox.api.base:_retry_error_callback:37 - Kemono API call failed - {'ret': APIRet(code=1002, message="1 validation error for Response\n Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\\n<html>\\...>\\n </body>\\n</html>\\n', input_type=str]\n For further information visit https://errors.pydantic.dev/2.7/v/json_invalid", exception=1 validation error for Response
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\n<html>\...>\n </body>\n</html>\n', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/json_invalid, data=None)}
1 validation error for Response
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\n<html>\...>\n </body>\n</html>\n', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/json_invalid
```

This is generally caused by frequent requests, so you can try setting a higher number of API retry attempts.

```dotenv
# .env / prod.env
KTOOLBOX_API__RETRY_TIMES=10
```

You can also set this through the graphical configuration editor: API - retry_times.

## Others

A community-shared usage guide: [#141](https://github.com/Ljzd-PRO/KToolBox/issues/141)
2 changes: 0 additions & 2 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
</a>
</p>

<img src="https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-1.png" alt="Preview">

## Features

- Support for **multi-thread** downloads (technically, coroutine)
Expand Down
17 changes: 13 additions & 4 deletions docs/zh/configuration/guide.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# 向导

!!! tip "图形化配置编辑器"
运行 `ktoolbox config-editor` 来启动,这会使配置编辑变得简单方便。

=== "用法"

运行 `ktoolbox config-editor` 来启动,这会使配置编辑变得简单方便。

- 按下 `<Esc>` 来返回,按 `<Enter>` 来选择
- 你也可以通过鼠标使用这个 GUI

=== "截图"

![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png){ loading=lazy }
![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png){ loading=lazy }

!!! tip "生成示例 `.env` 文件"
运行 `ktoolbox example-env` 来生成完整的配置文件样例。

![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-2.png)
![KToolBox 配置编辑器](https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-3.png)
运行 `ktoolbox example-env` 来生成完整的配置文件样例。

- KToolBox 读取 **工作目录** 下的 **`.env``prod.env` 文件****环境变量** 来设定配置
- 前往 [参考](./reference.md) 查看所有配置选项
Expand Down
69 changes: 68 additions & 1 deletion docs/zh/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,71 @@ KTOOLBOX_JOB__SEQUENTIAL_FILENAME=True
# 设置作品目录名为其发布日期和ID,例如 `[2024-1-1]11223344`
KTOOLBOX_JOB__POST_DIRNAME_FORMAT=[{published}]{id}
```
```

## 如何配置代理?

可以通过设置 `HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY` 环境变量实现

参考:[HTTPX - Environment Variables](https://www.python-httpx.org/environment_variables/#http_proxy-https_proxy-all_proxy)

例如这样设置:

```shell
# Unix Shell
export HTTPS_PROXY=http://127.0.0.1:7897
export HTTP_PROXY=http://127.0.0.1:7897
export ALL_PROXY=socks5://127.0.0.1:7897
```

```powershell
# Windows PowerShell
$env:HTTP_PROXY="http://127.0.0.1:7897"; $env:HTTPS_PROXY="http://127.0.0.1:7897"
```

## 图形化配置编辑器无法打开

!!! warning "注意"
[`ktoolbox-pure-py`](https://pypi.org/project/ktoolbox-pure-py/) 不支持图形化配置编辑器

默认情况下,图形化配置编辑器的相关依赖不会被安装,可使用以下命令附带安装:

```shell
pip3 install ktoolbox[urwid]
```

如果你用的是 pipx:

```shell
pipx install ktoolbox[urwid] --force
```

## Kemono API 调用失败

例如:

```
ktoolbox sync-creator "https://coomer.su/onlyfans/user/hollyharper11" --start-time="2020-05-01" --end-time="2025-01-01"
2024-05-12 12:52:51.477 | INFO | ktoolbox.cli:sync_creator:271 - Got creator information - {'name': 'hollyharper11', 'id': 'hollyharper11'}
2024-05-12 12:52:51.479 | INFO | ktoolbox.action.job:create_job_from_creator:148 - Start fetching posts from creator hollyharper11
2024-05-12 12:52:56.477 | ERROR | ktoolbox.api.base:_retry_error_callback:37 - Kemono API call failed - {'ret': APIRet(code=1002, message="1 validation error for Response\n Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\\n<html>\\...>\\n </body>\\n</html>\\n', input_type=str]\n For further information visit https://errors.pydantic.dev/2.7/v/json_invalid", exception=1 validation error for Response
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\n<html>\...>\n </body>\n</html>\n', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/json_invalid, data=None)}
1 validation error for Response
Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='<!DOCTYPE html>\n<html>\...>\n </body>\n</html>\n', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/json_invalid
```

一般可能是因为请求频繁导致,你可以尝试设置更多的 API 重试次数

```dotenv
# .env / prod.env
KTOOLBOX_API__RETRY_TIMES=10
```

你也可以通过图形化配置编辑器设置:API - retry_times

## 其他

一个社区分享的使用向导:[#141](https://github.com/Ljzd-PRO/KToolBox/issues/141)
2 changes: 0 additions & 2 deletions docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
</a>
</p>

<img src="https://cdn.jsdelivr.net/gh/Ljzd-PRO/KToolBox@latest/static/preview-1.png" alt="Preview">

## 功能

- 支持 **多线程** 下载(技术上是协程)
Expand Down
2 changes: 1 addition & 1 deletion ktoolbox/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class LoggerConfiguration(BaseModel):
:ivar rotation: Log rotation
"""
path: Optional[Path] = None
level: Union[str, int] = logging.DEBUG
level: Union[str, int] = logging.getLevelName(logging.DEBUG)
rotation: Union[str, int, datetime.time, datetime.timedelta] = "1 week"


Expand Down
Binary file modified static/preview-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/preview-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f6e535f

Please sign in to comment.