diff --git a/src/main/java/com/yutou/bilibili/Tools/ApplicationTime.java b/src/main/java/com/yutou/bilibili/Tools/ApplicationTime.java new file mode 100644 index 0000000..56bca9d --- /dev/null +++ b/src/main/java/com/yutou/bilibili/Tools/ApplicationTime.java @@ -0,0 +1,22 @@ +package com.yutou.bilibili.Tools; + +import com.yutou.bilibili.services.LiveDanmuService; +import com.yutou.bilibili.services.LiveVideoDownloadService; +import jakarta.annotation.Resource; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Component +@EnableScheduling +public class ApplicationTime { + @Resource + LiveVideoDownloadService videoService; + @Resource + LiveDanmuService danmuService; + @Scheduled(cron = "1 0 * * * *") + public void reset(){ + videoService.clearUserStopList(); + danmuService.clearUserList(); + } +} diff --git a/src/main/java/com/yutou/bilibili/services/SystemService.java b/src/main/java/com/yutou/bilibili/services/SystemService.java index 7429bd2..3c50861 100644 --- a/src/main/java/com/yutou/bilibili/services/SystemService.java +++ b/src/main/java/com/yutou/bilibili/services/SystemService.java @@ -37,7 +37,6 @@ public class SystemService { return config.getTimerLoop(); } - private final String resetTimer = "00:00:00 - 00:01:00"; public void start() { if (timer == null) { @@ -50,10 +49,6 @@ public class SystemService { scheduled = timer.scheduleAtFixedRate(() -> { List list = databasesService.getConfigDatabase().getAllConfig(); Log.i("循环任务:" + list.size()); - if (DateFormatUtils.getInstance().checkTime(null, resetTimer)) { - videoService.clearUserStopList(); - danmuService.clearUserList(); - } for (LiveConfigDatabaseBean bean : list) { try { // 如果bean需要录制弹幕,并且检查录制弹幕时间,并且不需要同步直播弹幕,则录制弹幕