feat: 完整采集采购尺码候选 (#256)
This commit is contained in:
@@ -1182,6 +1182,15 @@ class PddCollectService:
|
||||
artifacts=tuple(self._artifacts),
|
||||
)
|
||||
|
||||
def collect_second_dimension_candidates(
|
||||
self, device: Any
|
||||
) -> Optional[SpecDimension]:
|
||||
"""复用采集流程完整遍历当前颜色的第二规格,不点击任何选项。"""
|
||||
|
||||
return self._collect_size_dimension(
|
||||
device, require_confirmed_edges=True
|
||||
)
|
||||
|
||||
def _check_cancelled(self) -> None:
|
||||
if self._cancelled():
|
||||
raise PddCollectError("PDD_CANCELLED", "采集任务已安全取消")
|
||||
@@ -1926,7 +1935,12 @@ class PddCollectService:
|
||||
break
|
||||
return latest_xml
|
||||
|
||||
def _collect_size_dimension(self, device: Any) -> Optional[SpecDimension]:
|
||||
def _collect_size_dimension(
|
||||
self,
|
||||
device: Any,
|
||||
*,
|
||||
require_confirmed_edges: bool = False,
|
||||
) -> Optional[SpecDimension]:
|
||||
"""完整遍历第二规格并收集文字,全程不点击尺码或套餐。"""
|
||||
|
||||
sizes: dict[str, bool] = {}
|
||||
@@ -2008,7 +2022,10 @@ class PddCollectService:
|
||||
continuation = self._build_second_dimension_context(
|
||||
xml_data, initial_size_dimension
|
||||
)
|
||||
strict_edge_check = "套餐" in size_name and self._max_spec_swipes > 0
|
||||
strict_edge_check = (
|
||||
require_confirmed_edges
|
||||
or ("套餐" in size_name and self._max_spec_swipes > 0)
|
||||
)
|
||||
if strict_edge_check and not start_confirmed:
|
||||
raise PddCollectError(
|
||||
"PDD_DATA_SPEC_INCOMPLETE",
|
||||
@@ -2051,6 +2068,16 @@ class PddCollectService:
|
||||
option_text = self._second_dimension_option_text(value.text)
|
||||
if option_text is None:
|
||||
continue
|
||||
if (
|
||||
require_confirmed_edges
|
||||
and option_text in sizes
|
||||
and sizes[option_text] != value.available
|
||||
):
|
||||
raise PddCollectError(
|
||||
"PDD_DATA_SPEC_INCOMPLETE",
|
||||
f"完整遍历时第二规格状态发生变化:{size_name}",
|
||||
{"dimension_name": size_name},
|
||||
)
|
||||
sizes[option_text] = sizes.get(option_text, False) or value.available
|
||||
|
||||
signature = self._second_dimension_signature(xml_data, size_dimension)
|
||||
|
||||
Reference in New Issue
Block a user