Skip to content

Commit

Permalink
feat: not query unaired episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Nov 5, 2024
1 parent 7b02eea commit a0431df
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions server/core/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"polaris/pkg"
"polaris/pkg/notifier/message"
"polaris/pkg/utils"
"time"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -269,6 +270,20 @@ func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
if ep.Status != episode.StatusMissing {
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 {
name, err := c.SearchAndDownload(id, seasonNum, -1)
Expand All @@ -289,6 +304,20 @@ func (c *Client) DownloadSeriesAllEpisodes(id int) []string {
if ep.Status != episode.StatusMissing {
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)
if err != nil {
log.Warnf("finding resoruces of season %d episode %d error: %v", ep.SeasonNumber, ep.EpisodeNumber, err)
Expand Down Expand Up @@ -377,12 +406,12 @@ func (c *Client) downloadMovieSingleEpisode(ep *ent.Episode, targetDir string) (
torrent.Start()

history, err := c.db.SaveHistoryRecord(ent.History{
MediaID: ep.MediaID,
EpisodeID: ep.ID,
SourceTitle: r1.Name,
TargetDir: targetDir,
Status: history.StatusRunning,
Size: r1.Size,
MediaID: ep.MediaID,
EpisodeID: ep.ID,
SourceTitle: r1.Name,
TargetDir: targetDir,
Status: history.StatusRunning,
Size: r1.Size,
//Saved: torrent.Save(),
Link: magnet,
DownloadClientID: dlc.ID,
Expand Down

0 comments on commit a0431df

Please sign in to comment.