From 5490fb18e215a7accdc67743441211368511c6d8 Mon Sep 17 00:00:00 2001 From: Ljzd-PRO <63289359+Ljzd-PRO@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:51:49 +0800 Subject: [PATCH] fix: fixed TypeError: unsupported operand type(s) for //: 'NoneType' and 'int' --- ktoolbox/action/job.py | 11 ++++++++--- ktoolbox/cli.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ktoolbox/action/job.py b/ktoolbox/action/job.py index 2f4c06f..0e191d2 100644 --- a/ktoolbox/action/job.py +++ b/ktoolbox/action/job.py @@ -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], @@ -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): @@ -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: diff --git a/ktoolbox/cli.py b/ktoolbox/cli.py index 6b3862b..e45d5a2 100644 --- a/ktoolbox/cli.py +++ b/ktoolbox/cli.py @@ -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: