feat: not query unaired episodes

This commit is contained in:
Simon Ding
2024-11-05 19:17:46 +08:00
parent 7b02eeac51
commit a0431df1ee

View File

@@ -12,6 +12,7 @@ import (
"polaris/pkg" "polaris/pkg"
"polaris/pkg/notifier/message" "polaris/pkg/notifier/message"
"polaris/pkg/utils" "polaris/pkg/utils"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@@ -269,6 +270,20 @@ func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
if ep.Status != episode.StatusMissing { if ep.Status != episode.StatusMissing {
wantedSeasonPack = false wantedSeasonPack = false
} }
if ep.AirDate != "" {
t, err := time.Parse("2006-01-02", ep.AirDate)
if err != nil {
continue
}
/*
-------- now ------ t -----
t - 1day < now 要检测的剧集
提前一天开始检测
*/
if time.Now().Before(t.Add(-24 * time.Hour)) { //not aired
wantedSeasonPack = false
}
}
} }
if wantedSeasonPack { if wantedSeasonPack {
name, err := c.SearchAndDownload(id, seasonNum, -1) name, err := c.SearchAndDownload(id, seasonNum, -1)
@@ -289,6 +304,20 @@ func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
if ep.Status != episode.StatusMissing { if ep.Status != episode.StatusMissing {
continue continue
} }
if ep.AirDate != "" {
if t, err := time.Parse("2006-01-02", ep.AirDate); err == nil {
/*
-------- now ------ t -----
t - 1day < now 要检测的剧集
提前一天开始检测
*/
if time.Now().Before(t.Add(-24 * time.Hour)) { //not aired
continue
}
}
}
name, err := c.SearchAndDownload(id, ep.SeasonNumber, ep.EpisodeNumber) name, err := c.SearchAndDownload(id, ep.SeasonNumber, ep.EpisodeNumber)
if err != nil { if err != nil {
log.Warnf("finding resoruces of season %d episode %d error: %v", ep.SeasonNumber, ep.EpisodeNumber, err) log.Warnf("finding resoruces of season %d episode %d error: %v", ep.SeasonNumber, ep.EpisodeNumber, err)