Skip to content

Commit 68fd158

Browse files
authored
Merge pull request #347 from Ljzd-PRO/devel
Bump to v0.23.0
2 parents 502ff19 + d7330d3 commit 68fd158

File tree

16 files changed

+887
-358
lines changed

16 files changed

+887
-358
lines changed

CHANGELOG.md

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,86 @@
11
## Changes
22

3-
![Downloads](https://img.shields.io/github/downloads/Ljzd-PRO/KToolBox/v0.22.0/total)
3+
![Downloads](https://img.shields.io/github/downloads/Ljzd-PRO/KToolBox/v0.23.0/total)
44

55
### ✨ Features
66

7-
- Added `job.download_file` and `job.download_attachments` configuration options to control **whether to download files and attachments in posts**
8-
- Related configuration options:
9-
- `job.download_file` (default: `True`): Whether to download the file corresponding to the `file` field of the post (usually the cover image)
10-
- `job.download_attachments` (default: `True`): Whether to download files corresponding to the `attachments` field of the post (usually original images, compressed packages, etc.)
11-
- These options are enabled by default to maintain the same behavior as previous versions
12-
- You can edit these options via `ktoolbox config-editor` (`Job -> ...`)
13-
- Or manually edit them in the `.env` file or environment variables:
7+
- Added configuration options to support **filtering** downloads by **file size** - #343
8+
- You can set the minimum and maximum file size (in bytes) via `job.min_file_size` and `job.max_file_size`
9+
- Both options can be set together to define a file size range
10+
- Configure these options using the graphical config editor, or set them in the dotenv file `.env` or via system environment variables:
1411
```dotenv
15-
# Whether to download the file corresponding to the `file` field of the post (usually the cover image)
16-
# Download enabled by default
17-
KTOOLBOX_JOB__DOWNLOAD_FILE=False
12+
# Skip files smaller than 1 MB (to avoid downloading thumbnails)
13+
KTOOLBOX_JOB__MIN_FILE_SIZE=1048576
1814
19-
# Whether to download files corresponding to the `attachments` field of the post (usually original images, compressed packages, etc.)
20-
# Download enabled by default
21-
KTOOLBOX_JOB__DOWNLOAD_ATTACHMENTS=True
15+
# Skip files larger than 50 MB (to save disk space)
16+
KTOOLBOX_JOB__MAX_FILE_SIZE=52428800
17+
```
18+
- 📖 More info: [Configuration-Reference-JobConfiguration](https://ktoolbox.readthedocs.io/latest/configuration/reference/#ktoolbox.configuration.JobConfiguration)
19+
- Improved progress bar output - #345
20+
- Fixed the issue of the download file progress bar **constantly reordering**
21+
- Added **visual overall progress bar**
22+
- Added display of **total download speed**
23+
- Enhanced the **color rendering** of the progress bar
24+
```
25+
🔄 [==>---------------------------] 9% | Jobs: 173/1870 | 3 running | 1694 waiting | 5.7MB/s
26+
27+
⠹ 0bh1EKTGt5Zg9nNaDAi25P... |███████████████████████████░░░| 3.7MB/4.0MB 92.5% ⚡ 1.9MB/s
28+
⠹ YV30J8ftUbE9dUkkJVCqvN... |███░░░░░░░░░░░░░░░░░░░░░░░░░░░| 527.0KB/4.1MB 12.5% ⚡ 1.9MB/s
29+
⠹ KvKMSpwB4rRknTPKhEiXle... |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░| 95.0KB/3.8MB 2.5% ⚡ 1.9MB/s
2230
```
23-
- 📖 More information: [Configuration Reference - JobConfiguration](https://ktoolbox.readthedocs.io/latest/zh/configuration/reference/#ktoolbox._configuration_zh.JobConfiguration)
2431
25-
[//]: # (### 🪲 Fixes)
32+
### 🪲 Fixes
33+
34+
- **Increased** the default **tps limit** (maximum number of connections established per second)
35+
- This setting is optional. To **improve download efficiency** in general cases, the default value has been increased from `1.0` to `5.0`
36+
- If you frequently encounter **403** errors during downloads, try setting this value lower, such as `1.0`
37+
- Run `ktoolbox config-editor` to edit this setting (`Downloader -> tps_limit`)
38+
- Or manually edit the `KTOOLBOX_DOWNLOADER__TPS_LIMIT` in the `.env` file or set it via environment variables
39+
```dotenv
40+
KTOOLBOX_DOWNLOADER__TPS_LIMIT=1.0
41+
```
42+
- 📖 More info: [Configuration-Reference-DownloaderConfiguration](https://ktoolbox.readthedocs.io/latest/configuration/reference/#ktoolbox.configuration.DownloaderConfiguration)
2643
2744
- - -
2845
2946
### ✨ 新特性
3047
31-
- 新增 `job.download_file` 和 `job.download_attachments` 配置项,控制**是否下载帖子中的文件和附件**
32-
- 相关配置项:
33-
- `job.download_file`(默认值:`True`):是否下载帖子的 `file` 字段对应的文件(通常是帖子封面图)
34-
- `job.download_attachments`(默认值:`True`):是否下载帖子的 `attachments` 字段对应的文件(通常是帖子中的正式原图、压缩包等附件)
35-
- 该配置项默认均为开启状态,保持与之前版本一致的行为
36-
- 可通过运行 `ktoolbox config-editor` 编辑这些配置(`Job -> ...`)
37-
- 或手动在 `.env` 文件或环境变量中编辑:
48+
- 增加配置项以支持**按文件大小过滤**下载 - #343
49+
- 通过配置 `job.min_file_size` 和 `job.max_file_size` 来设置最小和最大文件大小(单位:字节)
50+
- 你可以同时设置这两个选项来定义一个文件大小范围
51+
- 通过图形化配置编辑器或在 dotenv 文件 `.env` 或系统环境变量中设置这些配置:
3852
```dotenv
39-
# 是否下载帖子的 `file` 字段对应的文件(通常是帖子封面图)
40-
# 默认开启下载
41-
KTOOLBOX_JOB__DOWNLOAD_FILE=False
53+
# 跳过小于 1 MB 的文件 (避免下载到缩略图)
54+
KTOOLBOX_JOB__MIN_FILE_SIZE=1048576
4255
43-
# 是否下载帖子的 `attachments` 字段对应的文件(通常是帖子中的正式原图、压缩包等附件)
44-
# 默认开启下载
45-
KTOOLBOX_JOB__DOWNLOAD_ATTACHMENTS=True
56+
# 跳过大于 50 MB 的文件 (节省磁盘空间)
57+
KTOOLBOX_JOB__MAX_FILE_SIZE=52428800
4658
```
47-
- 📖更多信息:[配置参考-JobConfiguration](https://ktoolbox.readthedocs.io/latest/zh/configuration/reference/#ktoolbox._configuration_zh.JobConfiguration)
59+
- 📖 更多信息:[Configuration-Reference-JobConfiguration](https://ktoolbox.readthedocs.io/latest/zh/configuration/reference/#ktoolbox._configuration_zh.JobConfiguration)
60+
- 改进进度条输出 - #345
61+
- 修复了下载文件进度条**不断重新排序**的问题
62+
- 增加了**可视化的总进度条**
63+
- 增加了下载**总速度**显示
64+
- 增加了进度条的**颜色渲染**
65+
```
66+
🔄 [==>---------------------------] 9% | Jobs: 173/1870 | 3 running | 1694 waiting | 5.7MB/s
67+
68+
⠹ 0bh1EKTGt5Zg9nNaDAi25P... |███████████████████████████░░░| 3.7MB/4.0MB 92.5% ⚡ 1.9MB/s
69+
⠹ YV30J8ftUbE9dUkkJVCqvN... |███░░░░░░░░░░░░░░░░░░░░░░░░░░░| 527.0KB/4.1MB 12.5% ⚡ 1.9MB/s
70+
⠹ KvKMSpwB4rRknTPKhEiXle... |░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░| 95.0KB/3.8MB 2.5% ⚡ 1.9MB/s
71+
```
72+
73+
### 🪲 修复
4874
49-
[//]: # (### 🪲 修复)
75+
- **提高**了默认的 **tps limit** (每秒最多建立的连接数)
76+
- 这项配置是可选的,为了**提高一般情况下的下载效率**,现在的默认值从 `1.0` 提升到了 `5.0`
77+
- 当下载频繁出现 **403** 错误时,可尝试将此设置改为较低值,如 `1.0`
78+
- 执行 `ktoolbox config-editor` 来编辑这项配置 (`Downloader -> tps_limit`)
79+
- 或手动编辑 `.env` 文件中的 `KTOOLBOX_DOWNLOADER__TPS_LIMIT` 或环境变量来设置这项配置
80+
```dotenv
81+
KTOOLBOX_DOWNLOADER__TPS_LIMIT=1.0
82+
```
83+
- 📖更多信息:[Configuration-Reference-DownloaderConfiguration](https://ktoolbox.readthedocs.io/latest/zh/configuration/reference/#ktoolbox._configuration_zh.DownloaderConfiguration)
5084
5185
## Upgrade
5286
@@ -55,4 +89,4 @@ Use this command to upgrade if you are using **pipx**:
5589
pipx upgrade ktoolbox
5690
```
5791

58-
**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.21.1...v0.22.0
92+
**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.22.0...v0.23.0

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
- Such as `[2025-01-02]_TheTitle_1.jpg`, `[2025-01-02]_TheTitle_2.jpg`, `[2025-01-02]_TheTitle_3.jpg`, etc.
6868
- Support excluding **specified file formats** or downloading only specified formats
6969
- For example, if you don't want to download large and duplicate PSD or archive files, you can exclude `.psd` and `.zip` files in the config
70+
- Support filtering downloads by **file size**
71+
- For example, if you want to avoid downloading large video files when running out of disk space, you can set a maximum file size limit in the config
72+
- You can also set a minimum file size to skip downloading thumbnail or preview images
7073
- Support filtering downloads by post **title keywords**
7174
- For example, if you only want to download posts whose titles contain "表情" or "効果音差分", you can use the `sync-creator` command with the `--keywords` option
7275
- You can also exclude posts with specific keywords in the title using the `--keywords-exclude` option

README_zh-CN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
-`[2025-01-02]_TheTitle_1.jpg``[2025-01-02]_TheTitle_2.jpg``[2025-01-02]_TheTitle_3.jpg`
6969
- 支持排除 **指定格式** 的文件或仅下载指定格式的文件
7070
- 例如当你不想下载庞大重复的 PSD 和压缩包文件时,可以在配置中排除 `.psd``.zip` 文件
71+
- 支持按**文件大小**过滤下载
72+
- 例如,如果你想在磁盘空间不足时避免下载大型视频文件,可以在配置中设置最大文件大小限制
73+
- 你也可以设置最小文件大小,以跳过下载缩略图或预览图片
7174
- 支持按帖子**标题关键词**过滤下载
7275
- 例如你只想下载标题中包含“表情、効果音差分”的帖子,可以使用 `sync-creator` 命令的 `--keywords` 选项
7376
- 如果你想排除标题中包含指定关键词的帖子,可以使用 `--keywords-exclude` 选项

demo_colorama_progress.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Demonstration script for the new colorama-based progress bars
4+
Shows the new Unicode progress bar style: ━━━╺━━━━━━━
5+
"""
6+
7+
import time
8+
import sys
9+
from ktoolbox.progress import ProgressManager
10+
11+
def demo_colorama_progress():
12+
"""Demo the new colorama-based progress bar display"""
13+
print("🎨 Colorama Progress Bar Demo")
14+
print("=" * 50)
15+
16+
# Create progress manager with colors enabled
17+
manager = ProgressManager(max_workers=3, use_colors=True, use_emojis=True)
18+
manager.set_job_totals(10, completed=2, failed=0)
19+
20+
print(f"Colorama available: {manager.use_colors}")
21+
print(f"Terminal supports colors: {manager.use_colors}")
22+
print()
23+
24+
# Start display
25+
manager.start_display()
26+
27+
try:
28+
# Create progress bars to demonstrate the new Unicode style
29+
pbar1 = manager.create_progress_bar("image1.jpg", total=1000)
30+
pbar2 = manager.create_progress_bar("video.mp4", total=5000)
31+
pbar3 = manager.create_progress_bar("document.pdf", total=800)
32+
33+
# Simulate progress with different speeds
34+
for i in range(50):
35+
# Update progress bars at different rates
36+
pbar1.update(20)
37+
if i % 2 == 0:
38+
pbar2.update(100)
39+
if i % 3 == 0:
40+
pbar3.update(16)
41+
42+
# Update the display
43+
manager.update_display()
44+
time.sleep(0.1)
45+
46+
# Update job progress occasionally
47+
if i % 10 == 0:
48+
manager.update_job_progress(completed=2 + (i // 10))
49+
50+
# Mark some as finished
51+
pbar1.close()
52+
manager.update_job_progress(completed=4)
53+
54+
# Continue with remaining
55+
for i in range(30):
56+
pbar2.update(50)
57+
pbar3.update(10)
58+
manager.update_display()
59+
time.sleep(0.05)
60+
61+
pbar2.close()
62+
pbar3.close()
63+
manager.update_job_progress(completed=10)
64+
65+
# Show final state briefly
66+
time.sleep(1)
67+
68+
finally:
69+
manager.stop_display()
70+
71+
print("\n✅ Demo completed!")
72+
print("You should have seen:")
73+
print("- Pink/magenta progress bars with ━━━╺━━━━━━━ style (when colorama available)")
74+
print("- Gray remaining sections")
75+
print("- Overall job progress with visual bar")
76+
print("- Fallback to █░ characters when colorama not available")
77+
78+
if __name__ == "__main__":
79+
demo_colorama_progress()

docs/en/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
- Such as `[2025-01-02]_TheTitle_1.jpg`, `[2025-01-02]_TheTitle_2.jpg`, `[2025-01-02]_TheTitle_3.jpg`, etc.
5656
- Support excluding **specified file formats** or downloading only specified formats
5757
- For example, if you don't want to download large and duplicate PSD or archive files, you can exclude `.psd` and `.zip` files in the config
58+
- Support filtering downloads by **file size**
59+
- For example, if you want to avoid downloading large video files when running out of disk space, you can set a maximum file size limit in the config
60+
- You can also set a minimum file size to skip downloading thumbnail or preview images
5861
- Support filtering downloads by post **title keywords**
5962
- For example, if you only want to download posts whose titles contain "表情" or "効果音差分", you can use the `sync-creator` command with the `--keywords` option
6063
- You can also exclude posts with specific keywords in the title using the `--keywords-exclude` option

docs/zh/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
-`[2025-01-02]_TheTitle_1.jpg``[2025-01-02]_TheTitle_2.jpg``[2025-01-02]_TheTitle_3.jpg`
5757
- 支持排除 **指定格式** 的文件或仅下载指定格式的文件
5858
- 例如当你不想下载庞大重复的 PSD 和压缩包文件时,可以在配置中排除 `.psd``.zip` 文件
59+
- 支持按**文件大小**过滤下载
60+
- 例如,如果你想在磁盘空间不足时避免下载大型视频文件,可以在配置中设置最大文件大小限制
61+
- 你也可以设置最小文件大小,以跳过下载缩略图或预览图片
5962
- 支持按帖子**标题关键词**过滤下载
6063
- 例如你只想下载标题中包含“表情、効果音差分”的帖子,可以使用 `sync-creator` 命令的 `--keywords` 选项
6164
- 如果你想排除标题中包含指定关键词的帖子,可以使用 `--keywords-exclude` 选项

ktoolbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__title__ = "KToolBox"
22
# noinspection SpellCheckingInspection
33
__description__ = "A useful CLI tool for downloading posts in Kemono.cr / .su / .party"
4-
__version__ = "v0.22.0"
4+
__version__ = "v0.23.0"

ktoolbox/_configuration_zh.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class JobConfiguration(ktoolbox.configuration.JobConfiguration):
146146
:ivar keywords_exclude: 按帖子标题关键词排除(不区分大小写)
147147
:ivar download_file: 是否下载帖子文件(通常为封面图片)。设置为 False 可跳过文件下载。
148148
:ivar download_attachments: 是否下载帖子附件。设置为 False 可跳过附件下载。
149+
:ivar min_file_size: 最小文件大小(字节)。小于此大小的文件将被跳过。设置为 None 禁用最小文件大小过滤。
150+
:ivar max_file_size: 最大文件大小(字节)。大于此大小的文件将被跳过。设置为 None 禁用最大文件大小过滤。
149151
"""
150152
post_structure: PostStructureConfiguration = PostStructureConfiguration()
151153

ktoolbox/configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class DownloaderConfiguration(BaseModel):
7878
retry_times: int = 10
7979
retry_stop_never: bool = False
8080
retry_interval: float = 3.0
81-
tps_limit: float = 1.0
81+
tps_limit: float = 5.0
8282
use_bucket: bool = False
8383
bucket_path: Path = Path("./.ktoolbox/bucket_storage")
8484
reverse_proxy: str = "{}"
@@ -224,6 +224,10 @@ class JobConfiguration(BaseModel):
224224
:ivar keywords_exclude: keywords to exclude posts by title (case-insensitive)
225225
:ivar download_file: Download post file (usually cover image). Set to False to skip file downloads.
226226
:ivar download_attachments: Download post attachments. Set to False to skip attachment downloads.
227+
:ivar min_file_size: Minimum file size in bytes to download. Files smaller than this will be skipped. \
228+
Set to None to disable minimum size filtering.
229+
:ivar max_file_size: Maximum file size in bytes to download. Files larger than this will be skipped. \
230+
Set to None to disable maximum size filtering.
227231
"""
228232
count: int = 4
229233
include_revisions: bool = False
@@ -297,6 +301,8 @@ class JobConfiguration(BaseModel):
297301
keywords_exclude: Set[str] = Field(default_factory=set)
298302
download_file: bool = True
299303
download_attachments: bool = True
304+
min_file_size: Optional[int] = None
305+
max_file_size: Optional[int] = None
300306

301307

302308
class LoggerConfiguration(BaseModel):

0 commit comments

Comments
 (0)