mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-04 06:54:41 +08:00
30 lines
719 B
Go
30 lines
719 B
Go
package spider
|
|
|
|
import (
|
|
"github.com/robfig/cron/v3"
|
|
"log"
|
|
"server/config"
|
|
)
|
|
|
|
// RegularUpdateMovie 定时更新, 每半小时获取一次站点的最近x小时数据
|
|
func RegularUpdateMovie() {
|
|
c := cron.New(cron.WithSeconds())
|
|
// 开启定时任务每x 分钟更新一次最近x小时的影片数据
|
|
_, err := c.AddFunc(config.CornMovieUpdate, func() {
|
|
// 执行更新最近x小时影片的Spider
|
|
log.Println("执行一次影片更新任务...")
|
|
UpdateMovieDetail()
|
|
})
|
|
|
|
// 开启定时任务每月最后一天凌晨两点, 执行一次清库重取数据
|
|
_, err = c.AddFunc(config.CornUpdateAll, func() {
|
|
StartSpiderRe()
|
|
})
|
|
|
|
if err != nil {
|
|
log.Println("Corn Start Error: ", err)
|
|
}
|
|
|
|
c.Start()
|
|
}
|