Skip to content

Commit

Permalink
Merge branch 'devel' into pure-py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljzd-PRO committed Mar 29, 2024
2 parents 1677642 + 3f25719 commit 309a37d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

### 💡 Feature

- Add `--offset`, `--length` options in `sync-creator` command
- Added support for downloading works within a specified range of quantity.
- Added `--offset`, `--length` options in `sync-creator` command
- `--offset`: Posts result offset (or start offset)
- `--length`: The number of posts to fetch, defaults to fetching all posts

Expand All @@ -21,7 +22,8 @@

### 💡 新特性

-`sync-creator` 命令中增加了 `--offset`, `--length` 选项
- 增加下载指定数量范围作品的支持
-`sync-creator` 命令中增加了 `--offset`, `--length` 选项
- `--offset`:作品结果偏移量(或起始偏移量)
- `--length`:要获取的作品数量,默认获取所有作品

Expand Down
11 changes: 8 additions & 3 deletions ktoolbox/action/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def create_job_from_creator(
*,
all_pages: bool = False,
offset: int = 0,
length: int = 50,
length: Optional[int] = 50,
save_creator_indices: bool = True,
mix_posts: bool = None,
start_time: Optional[datetime],
Expand All @@ -125,8 +125,11 @@ async def create_job_from_creator(
logger.info(f"Start fetching posts from creator {creator_id}")
post_list: List[Post] = []
start_offset = offset - offset % 50
page_num = length // 50 + 1
page_counter = count() if all_pages else iter(range(page_num))
if all_pages:
page_counter = count()
else:
page_num = length // 50 + 1
page_counter = iter(range(page_num))

try:
async for part in fetch_creator_posts(service=service, creator_id=creator_id, o=start_offset):
Expand All @@ -139,6 +142,8 @@ async def create_job_from_creator(

if not all_pages:
post_list = post_list[offset % 50:][:length]
else:
post_list = post_list[offset % 50:]

# Filter posts by publish time
if start_time or end_time:
Expand Down
2 changes: 1 addition & 1 deletion ktoolbox/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def sync_creator(
Set to latest time (infinity) if ``None`` was given. \
Time format: ``%Y-%m-%d``
:param offset: Result offset (or start offset)
:param length: The number of posts to fetch, defaults to fetching all posts.
:param length: The number of posts to fetch, defaults to fetching all posts after ``offset``.
"""
# Get service, creator_id
if url:
Expand Down

0 comments on commit 309a37d

Please sign in to comment.