fix(api): 列表页失败不算完成
This commit is contained in:
@@ -378,7 +378,6 @@ class APIBrowser:
|
|||||||
page = 1
|
page = 1
|
||||||
base_url = None
|
base_url = None
|
||||||
skipped_items = 0
|
skipped_items = 0
|
||||||
skipped_pages = 0
|
|
||||||
consecutive_failures = 0
|
consecutive_failures = 0
|
||||||
max_consecutive_failures = 3
|
max_consecutive_failures = 3
|
||||||
|
|
||||||
@@ -435,15 +434,8 @@ class APIBrowser:
|
|||||||
if next_url:
|
if next_url:
|
||||||
base_url = next_url
|
base_url = next_url
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
skipped_pages += 1
|
self.log(f"[API] 获取第{page}页列表失败,终止本次浏览: {str(e)}")
|
||||||
consecutive_failures += 1
|
raise
|
||||||
self.log(
|
|
||||||
f"[API] 获取第{page}页列表失败,跳过本页(连续失败{consecutive_failures}/{max_consecutive_failures}): {str(e)}"
|
|
||||||
)
|
|
||||||
if consecutive_failures >= max_consecutive_failures:
|
|
||||||
raise
|
|
||||||
page += 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
for article in articles:
|
for article in articles:
|
||||||
if should_stop_callback and should_stop_callback():
|
if should_stop_callback and should_stop_callback():
|
||||||
@@ -480,10 +472,8 @@ class APIBrowser:
|
|||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
report_progress(force=True)
|
report_progress(force=True)
|
||||||
if skipped_items or skipped_pages:
|
if skipped_items:
|
||||||
self.log(
|
self.log(f"[API] 浏览完成: {total_items} 条内容,{total_attachments} 个附件(跳过 {skipped_items} 条内容)")
|
||||||
f"[API] 浏览完成: {total_items} 条内容,{total_attachments} 个附件(跳过 {skipped_items} 条内容,{skipped_pages} 页列表)"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.log(f"[API] 浏览完成: {total_items} 条内容,{total_attachments} 个附件")
|
self.log(f"[API] 浏览完成: {total_items} 条内容,{total_attachments} 个附件")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user