Kaynağa Gözat

feat: 设置页新增发布步间延时配置(irange类型)

- publish.delay_sec 暴露到设置页('30,180'整数对,乱序自动归一),
  发布快慢用户自调(默认[30,180]防风控,压短提速自担风险)
wubinggen 3 ay önce
ebeveyn
işleme
803032ddb7

+ 7 - 0
白盒重建/kuaishou_tool/ui.py

@@ -100,6 +100,7 @@ SETTINGS_FIELDS = [
     ('采集过滤', 'collect.filters.need_goods', '需挂车(无商品则过滤)', 'bool', True),
     ('采集过滤', 'collect.filters.need_goods', '需挂车(无商品则过滤)', 'bool', True),
     ('采集', 'collect.poll_interval_sec', '轮询间隔(秒)', 'int', 300),
     ('采集', 'collect.poll_interval_sec', '轮询间隔(秒)', 'int', 300),
     ('发布', 'publish.fragment_mb', '分片大小(MB)', 'int', 8),
     ('发布', 'publish.fragment_mb', '分片大小(MB)', 'int', 8),
+    ('发布', 'publish.delay_sec', '发布步间延时(秒,如 30,180)', 'irange', [30, 180]),
     ('发布', 'publish.daily_limit_per_account', '单账号日发布上限', 'int', 5),
     ('发布', 'publish.daily_limit_per_account', '单账号日发布上限', 'int', 5),
     ('AI生图', 'ai.model', '模型', 'str', 'cogview-3-flash'),
     ('AI生图', 'ai.model', '模型', 'str', 'cogview-3-flash'),
     ('AI生图', 'ai.image_size', '生图尺寸(WxH)', 'str', '1024x1024'),
     ('AI生图', 'ai.image_size', '生图尺寸(WxH)', 'str', '1024x1024'),
@@ -156,6 +157,8 @@ def form_values(cfg):
             vals[path] = '1' if v else '0'
             vals[path] = '1' if v else '0'
         elif typ == 'list':
         elif typ == 'list':
             vals[path] = ','.join(v)
             vals[path] = ','.join(v)
+        elif typ == 'irange':              # [a,b] → 'a,b'
+            vals[path] = ','.join(str(int(x)) for x in (v or []))
         else:
         else:
             vals[path] = str(v)
             vals[path] = str(v)
     return vals
     return vals
@@ -173,6 +176,10 @@ def apply_form(cfg, vals):
             _bury(cfg, path, float(raw or 0))
             _bury(cfg, path, float(raw or 0))
         elif typ == 'list':
         elif typ == 'list':
             _bury(cfg, path, [x.strip() for x in _LIST_SPLIT_RE.split(raw) if x.strip()])
             _bury(cfg, path, [x.strip() for x in _LIST_SPLIT_RE.split(raw) if x.strip()])
+        elif typ == 'irange':              # 'a,b' → [min(a,b), max(a,b)] 整数对
+            nums = [int(float(x)) for x in _LIST_SPLIT_RE.split(raw) if x.strip()]
+            pair = ([min(nums), max(nums)] + [0, 0])[:2] if nums else [30, 180]
+            _bury(cfg, path, pair)
         else:
         else:
             _bury(cfg, path, raw)
             _bury(cfg, path, raw)
 
 

+ 2 - 0
白盒重建/tests/test_ui.py

@@ -128,6 +128,7 @@ def test_apply_form_parsing():
         'collect.filters.need_goods': '0',            # bool
         'collect.filters.need_goods': '0',            # bool
         'ads.enabled': 'true',                        # bool 词形
         'ads.enabled': 'true',                        # bool 词形
         'ai.model': 'cogview-3-flash',                # str
         'ai.model': 'cogview-3-flash',                # str
+        'publish.delay_sec': '180, 30',               # irange:乱序→[30,180]
     })
     })
     assert cfg['collect']['filters']['min_likes'] == 12
     assert cfg['collect']['filters']['min_likes'] == 12
     assert cfg['collect']['filters']['max_age_hours'] == 2.5
     assert cfg['collect']['filters']['max_age_hours'] == 2.5
@@ -135,6 +136,7 @@ def test_apply_form_parsing():
     assert cfg['collect']['filters']['need_goods'] is False
     assert cfg['collect']['filters']['need_goods'] is False
     assert cfg['ads']['enabled'] is True
     assert cfg['ads']['enabled'] is True
     assert cfg['ai']['model'] == 'cogview-3-flash'
     assert cfg['ai']['model'] == 'cogview-3-flash'
+    assert cfg['publish']['delay_sec'] == [30, 180]
 
 
 
 
 def test_form_values_defaults():
 def test_form_values_defaults():