Skip to content

Commit cb730cc

Browse files
committed
feat: add keywords and keywords-exclude in configuration
1 parent ebb3d1b commit cb730cc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ktoolbox/cli.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,13 @@ async def sync_creator(
353353
return creator_ret.message
354354

355355
creator_path = path / sanitize_filename(creator_name)
356-
357356
creator_path.mkdir(exist_ok=True)
358357

359-
# Parse keywords
360-
keyword_set = set(keywords) if keywords else set()
358+
keyword_set = set(keywords) if keywords else config.job.keywords
361359
if keywords:
362360
logger.info(f"Filtering posts by keywords: {', '.join(keyword_set)}")
363361

364-
# Parse exclude keywords
365-
keyword_exclude_set = set(keywords_exclude) if keywords_exclude else set()
362+
keyword_exclude_set = set(keywords_exclude) if keywords_exclude else config.job.keywords_exclude
366363
if keywords_exclude:
367364
logger.info(f"Excluding posts by keywords: {', '.join(keyword_exclude_set)}")
368365

ktoolbox/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class JobConfiguration(BaseModel):
203203
e.g. ``{year}`` > ``2024``, ``Year_{year}`` > ``Year_2024``
204204
:ivar month_dirname_format: Customize the month directory name format. Available properties: ``year``, ``month``. \
205205
e.g. ``{year}-{month}`` > ``2024-01``, ``{year}_{month}`` > ``2024_01``
206+
:ivar keywords: keywords to filter posts by title (case-insensitive)
207+
:ivar keywords_exclude: keywords to exclude posts by title (case-insensitive)
206208
"""
207209
count: int = 4
208210
include_revisions: bool = False
@@ -269,6 +271,8 @@ class JobConfiguration(BaseModel):
269271
group_by_month: bool = False
270272
year_dirname_format: str = "{year}"
271273
month_dirname_format: str = "{year}-{month:02d}"
274+
keywords: Set[str] = Field(default_factory=set)
275+
keywords_exclude: Set[str] = Field(default_factory=set)
272276

273277

274278
class LoggerConfiguration(BaseModel):

0 commit comments

Comments
 (0)