diff --git a/plugins.v2/brushflow/__init__.py b/plugins.v2/brushflow/__init__.py index 08876ad..bbf3a3e 100644 --- a/plugins.v2/brushflow/__init__.py +++ b/plugins.v2/brushflow/__init__.py @@ -11,6 +11,7 @@ from urllib.parse import urlparse, parse_qs, unquote, parse_qsl, urlencode, urlu import pytz from app.helper.sites import SitesHelper from apscheduler.schedulers.background import BackgroundScheduler +from apscheduler.triggers.cron import CronTrigger from app import schemas from app.chain.torrents import TorrentsChain @@ -72,6 +73,7 @@ class BrushConfig: self.brush_sequential = config.get("brush_sequential", False) self.proxy_delete = config.get("proxy_delete", False) self.active_time_range = config.get("active_time_range") + self.cron = config.get("cron") self.qb_category = config.get("qb_category") self.site_hr_active = config.get("site_hr_active", False) self.site_skip_tips = config.get("site_skip_tips", False) @@ -431,14 +433,27 @@ class BrushFlow(_PluginBase): return services if self._task_brush_enable: - logger.info(f"站点刷流定时服务启动,时间间隔 {self._brush_interval} 分钟") - services.append({ - "id": "BrushFlow", - "name": "站点刷流服务", - "trigger": "interval", - "func": self.brush, - "kwargs": {"minutes": self._brush_interval} - }) + if brush_config.cron: + values = brush_config.cron.split() + values[0] = f"{datetime.now().minute % 10}/5" + cron = " ".join(values) + logger.info(f"站点刷流定时服务启动,执行周期 {cron}") + cron_trigger = CronTrigger.from_crontab(cron) + services.append({ + "id": "BrushFlow", + "name": "站点刷流服务", + "trigger": cron_trigger, + "func": self.brush + }) + else: + logger.info(f"站点刷流定时服务启动,时间间隔 {self._brush_interval} 分钟") + services.append({ + "id": "BrushFlow", + "name": "站点刷流服务", + "trigger": "interval", + "func": self.brush, + "kwargs": {"minutes": self._brush_interval} + }) if brush_config.enabled: logger.info(f"站点刷流检查定时服务启动,时间间隔 {self._check_interval} 分钟") @@ -888,7 +903,7 @@ class BrushFlow(_PluginBase): 'component': 'VCol', 'props': { "cols": 12, - "md": 4 + "md": 3 }, 'content': [ { @@ -905,7 +920,24 @@ class BrushFlow(_PluginBase): 'component': 'VCol', 'props': { "cols": 12, - "md": 4 + "md": 3 + }, + 'content': [ + { + 'component': 'VTextField', + 'props': { + 'model': 'cron', + 'label': '执行周期', + 'placeholder': '如:0 0-1 * * FRI,SUN' + } + } + ] + }, + { + 'component': 'VCol', + 'props': { + "cols": 12, + "md": 3 }, 'content': [ { @@ -922,7 +954,7 @@ class BrushFlow(_PluginBase): 'component': 'VCol', 'props': { "cols": 12, - "md": 4 + "md": 3 }, 'content': [ { @@ -2945,6 +2977,7 @@ class BrushFlow(_PluginBase): "brush_sequential": brush_config.brush_sequential, "proxy_delete": brush_config.proxy_delete, "active_time_range": brush_config.active_time_range, + "cron": brush_config.cron, "qb_category": brush_config.qb_category, "enable_site_config": brush_config.enable_site_config, "site_config": brush_config.site_config,