feat(collect): choose product status scope

This commit is contained in:
chengma
2026-07-18 16:46:59 +08:00
parent 0cf23db403
commit 4658a1ca61
11 changed files with 420 additions and 41 deletions
+35 -20
View File
@@ -1166,26 +1166,41 @@ def collect(account, task, on_step=None) -> dict:
try:
_notify_collect_step(on_step, "read_product_status")
status_snapshot = read_product_status(cdp)
_notify_collect_step(on_step, "read_title")
old_title = read_title(cdp)
_notify_collect_step(on_step, "read_cover")
old_cover_src = read_cover_src(cdp)
out_path = _get(task, "old_cover_path")
if not out_path:
out_path = image_paths.task_image_path(
appconfig.image_dir(),
task,
account,
"old",
)
_notify_collect_step(on_step, "download_cover")
old_cover_path = download_cover(old_cover_src, out_path)
result = {
"old_title": old_title,
"old_cover_src": old_cover_src,
"old_cover_path": old_cover_path,
**status_snapshot,
}
collect_scope = product_status.normalize_collect_scope(
_get(task, "collection_scope")
)
if not product_status.should_collect_content(
status_snapshot.get("product_status"),
collect_scope,
):
result = {
**status_snapshot,
"collection_skipped": True,
"collection_skip_reason": product_status.collect_skip_reason(
status_snapshot.get("product_status")
),
}
else:
_notify_collect_step(on_step, "read_title")
old_title = read_title(cdp)
_notify_collect_step(on_step, "read_cover")
old_cover_src = read_cover_src(cdp)
out_path = _get(task, "old_cover_path")
if not out_path:
out_path = image_paths.task_image_path(
appconfig.image_dir(),
task,
account,
"old",
)
_notify_collect_step(on_step, "download_cover")
old_cover_path = download_cover(old_cover_src, out_path)
result = {
"old_title": old_title,
"old_cover_src": old_cover_src,
"old_cover_path": old_cover_path,
**status_snapshot,
}
finally:
close_target_confirmed = _close_collected_product(cdp)
result["close_target_confirmed"] = close_target_confirmed