Skip to content

Commit df65915

Browse files
committed
Merge branch 'devel'
# Conflicts: # CHANGELOG.md
2 parents 7605c8c + 2914d21 commit df65915

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

CHANGELOG.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
## Changes
22

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

55
### 💡 Feature
66

7-
- Improved the error log format to make it easier to read and understand
7+
> - Improved the error log format to make it easier to read and understand (v0.19.1)
88
99
### 🪲 Fix
1010

11-
- Fixed the issue where author information and work data could not be retrieved due to **Kemono API changes** - #315
12-
- Error messages: `Kemono API call failed: ...`, `404 Not Found`, `403 Forbidden`, ...
11+
- Fixed the issue where **`content`** data of works could not be obtained due to **Kemono API changes**, resulting in missing **`content.txt`** and `external_links.txt` - #316
12+
> - Fixed the issue where author information and work data could not be retrieved due to **Kemono API changes** - #315 (v0.19.1)
13+
> - Error messages: `Kemono API call failed: ...`, `404 Not Found`, `403 Forbidden`, ...
1314
1415
- - -
1516

1617
### 💡 新特性
1718

18-
- 改进报错的日志格式,使其更易于阅读和理解
19+
> - 改进报错的日志格式,使其更易于阅读和理解 (v0.19.1)
1920
2021
### 🪲 修复
2122

22-
- 修复 Kemono **API 变更**导致的作者信息和作品数据**获取失败**的问题 - #315
23-
- 报错信息:`Kemono API call failed: ...`, `404 Not Found`, `403 Forbidden`, ...
23+
- 修复由于 **Kemono API 变更** 导致的作品 **`content`** 数据无法获取进而导致 **`content.txt`, `external_links.txt` 缺失**的问题 - #316
24+
> - 修复 Kemono **API 变更**导致的作者信息和作品数据**获取失败**的问题 - #315 (v0.19.1)
25+
> - 报错信息:`Kemono API call failed: ...`, `404 Not Found`, `403 Forbidden`, ...
2426
2527
## Upgrade
2628

@@ -29,4 +31,4 @@ Use this command to upgrade if you are using **pipx**:
2931
pipx upgrade ktoolbox
3032
```
3133

32-
**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.19.0...v0.19.1
34+
**Full Changelog**: https://github.com/Ljzd-PRO/KToolBox/compare/v0.19.1...v0.19.2

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.19.1"
4+
__version__ = "v0.19.2"

ktoolbox/action/job.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
from ktoolbox._enum import PostFileTypeEnum, DataStorageNameEnum
1313
from ktoolbox.action import ActionRet, fetch_creator_posts, FetchInterruptError
14-
from ktoolbox.action.utils import generate_post_path_name, filter_posts_by_date, generate_filename, filter_posts_by_keywords, filter_posts_by_keywords_exclude, generate_grouped_post_path
15-
from ktoolbox.api.model import Post, Attachment
16-
from ktoolbox.api.posts import get_post_revisions as get_post_revisions_api
14+
from ktoolbox.action.utils import generate_post_path_name, filter_posts_by_date, generate_filename, \
15+
filter_posts_by_keywords, filter_posts_by_keywords_exclude, generate_grouped_post_path
16+
from ktoolbox.api.model import Post, Attachment, Revision
17+
from ktoolbox.api.posts import get_post_revisions as get_post_revisions_api, get_post as get_post_api
1718
from ktoolbox.configuration import config, PostStructureConfiguration
1819
from ktoolbox.job import Job, CreatorIndices
1920
from ktoolbox.utils import extract_external_links
@@ -22,7 +23,7 @@
2223

2324

2425
async def create_job_from_post(
25-
post: Post,
26+
post: Union[Post, Revision],
2627
post_path: Path,
2728
*,
2829
post_structure: Union[PostStructureConfiguration, bool] = None,
@@ -75,8 +76,8 @@ async def create_job_from_post(
7576
)
7677
):
7778
# Check if file extension should be excluded from sequential naming
78-
should_use_sequential = (config.job.sequential_filename and
79-
file_path_obj.suffix.lower() not in config.job.sequential_filename_excludes)
79+
should_use_sequential = (config.job.sequential_filename and
80+
file_path_obj.suffix.lower() not in config.job.sequential_filename_excludes)
8081
if should_use_sequential:
8182
basic_filename = f"{sequential_counter}{file_path_obj.suffix}"
8283
sequential_counter += 1
@@ -120,6 +121,17 @@ async def create_job_from_post(
120121
)
121122
)
122123

124+
# If post has no content, fetch it from get_post API
125+
if not post.content:
126+
get_post_ret = await get_post_api(
127+
service=post.service,
128+
creator_id=post.user,
129+
post_id=post.id,
130+
revision_id=post.revision_id if isinstance(post, Revision) else None
131+
)
132+
if get_post_ret:
133+
post = get_post_ret.data.post
134+
123135
# Write content file
124136
if content_path and post.content:
125137
async with aiofiles.open(content_path, "w", encoding=config.downloader.encoding) as f:
@@ -204,15 +216,15 @@ async def create_job_from_creator(
204216
# Filter posts by publish time
205217
if start_time or end_time:
206218
post_list = list(filter_posts_by_date(post_list, start_time, end_time))
207-
219+
208220
# Filter posts by keywords
209221
if keywords:
210222
post_list = list(filter_posts_by_keywords(post_list, keywords))
211-
223+
212224
# Filter out posts by exclude keywords
213225
if keywords_exclude:
214226
post_list = list(filter_posts_by_keywords_exclude(post_list, keywords_exclude))
215-
227+
216228
logger.info(f"Get {len(post_list)} posts after filtering, start creating jobs")
217229

218230
# Filter posts and generate ``CreatorIndices``
@@ -223,7 +235,7 @@ async def create_job_from_creator(
223235
for post in post_list:
224236
grouped_base_path = generate_grouped_post_path(post, path)
225237
posts_path[post.id] = grouped_base_path / sanitize_filename(post.title)
226-
238+
227239
indices = CreatorIndices(
228240
creator_id=creator_id,
229241
service=service,
@@ -258,7 +270,7 @@ async def create_job_from_creator(
258270
post_structure=False if mix_posts else None,
259271
dump_post_data=not mix_posts
260272
)
261-
273+
262274
# If include_revisions is enabled, fetch and download revisions for this post
263275
if config.job.include_revisions and not mix_posts:
264276
try:
@@ -270,7 +282,8 @@ async def create_job_from_creator(
270282
if revisions_ret and revisions_ret.data:
271283
for revision in revisions_ret.data:
272284
if revision.revision_id: # Only process actual revisions
273-
revision_path = post_path / config.job.post_structure.revisions / generate_post_path_name(revision)
285+
revision_path = post_path / config.job.post_structure.revisions / generate_post_path_name(
286+
revision)
274287
revision_jobs = await create_job_from_post(
275288
post=revision,
276289
post_path=revision_path,
@@ -279,5 +292,5 @@ async def create_job_from_creator(
279292
job_list += revision_jobs
280293
except Exception as e:
281294
logger.warning(f"Failed to fetch revisions for post {post.id}: {e}")
282-
295+
283296
return ActionRet(data=job_list)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ktoolbox"
3-
version = "v0.19.1"
3+
version = "v0.19.2"
44
description = "A useful CLI tool for downloading posts in Kemono.cr / .su / .party"
55
authors = ["Ljzd-PRO <me@ljzd.link>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)