fix: monitor lastest season

This commit is contained in:
Simon Ding
2024-09-23 23:12:06 +08:00
parent f4ccc69b50
commit 89104785d7
2 changed files with 16 additions and 8 deletions

View File

@@ -133,14 +133,17 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
} else { } else {
detail = detailEn detail = detailEn
} }
log.Infof("find detail for tv id %d: %v", in.TmdbID, detail) log.Infof("find detail for tv id %d: %+v", in.TmdbID, detail)
maxSeason := 0 lastSeason := 0
for _, season := range detail.Seasons { for _, season := range detail.Seasons {
if season.SeasonNumber > maxSeason { if season.SeasonNumber > lastSeason && season.EpisodeCount > 0 { //如果最新一季已经有剧集信息,则以最新一季为准
maxSeason = season.SeasonNumber lastSeason = season.SeasonNumber
} }
} }
log.Debugf("latest season is %v", lastSeason)
var epIds []int var epIds []int
for _, season := range detail.Seasons { for _, season := range detail.Seasons {
seasonId := season.SeasonNumber seasonId := season.SeasonNumber
@@ -149,8 +152,11 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
log.Errorf("get season detail (%s) error: %v", detail.Name, err) log.Errorf("get season detail (%s) error: %v", detail.Name, err)
continue continue
} }
shouldMonitor := seasonId >= lastSeason //监控最新的一季
for _, ep := range se.Episodes { for _, ep := range se.Episodes {
shouldMonitor := season.SeasonNumber >= maxSeason //监控最新的一季
// //如果设置下载往期剧集则监控所有剧集。如果没有则监控未上映的剧集考虑时差等问题留24h余量 // //如果设置下载往期剧集则监控所有剧集。如果没有则监控未上映的剧集考虑时差等问题留24h余量
// if in.DownloadHistoryEpisodes { // if in.DownloadHistoryEpisodes {
// shouldMonitor = true // shouldMonitor = true
@@ -167,18 +173,20 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
// } // }
// } // }
epid, err := c.db.SaveEposideDetail(&ent.Episode{ ep := ent.Episode{
SeasonNumber: seasonId, SeasonNumber: seasonId,
EpisodeNumber: ep.EpisodeNumber, EpisodeNumber: ep.EpisodeNumber,
Title: ep.Name, Title: ep.Name,
Overview: ep.Overview, Overview: ep.Overview,
AirDate: ep.AirDate, AirDate: ep.AirDate,
Monitored: shouldMonitor, Monitored: shouldMonitor,
}) }
epid, err := c.db.SaveEposideDetail(&ep)
if err != nil { if err != nil {
log.Errorf("save episode info error: %v", err) log.Errorf("save episode info error: %v", err)
continue continue
} }
log.Debugf("success save episode %+v", ep)
epIds = append(epIds, epid) epIds = append(epIds, epid)
} }
} }

View File

@@ -115,7 +115,7 @@ class SearchPageData
if (sp.code != 0) { if (sp.code != 0) {
throw sp.message; throw sp.message;
} }
ref.invalidate(tvWatchlistDataProvider); //ref.invalidate(tvWatchlistDataProvider);
} else { } else {
var resp = await dio.post(APIs.watchlistMovieUrl, data: { var resp = await dio.post(APIs.watchlistMovieUrl, data: {
"tmdb_id": tmdbId, "tmdb_id": tmdbId,