Skip to content

Commit

Permalink
fix: monitor lastest season
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Sep 23, 2024
1 parent f4ccc69 commit 8910478
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions server/core/importlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
} else {
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 {
if season.SeasonNumber > maxSeason {
maxSeason = season.SeasonNumber
if season.SeasonNumber > lastSeason && season.EpisodeCount > 0 { //如果最新一季已经有剧集信息,则以最新一季为准
lastSeason = season.SeasonNumber
}
}

log.Debugf("latest season is %v", lastSeason)

var epIds []int
for _, season := range detail.Seasons {
seasonId := season.SeasonNumber
Expand All @@ -149,8 +152,11 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
log.Errorf("get season detail (%s) error: %v", detail.Name, err)
continue
}

shouldMonitor := seasonId >= lastSeason //监控最新的一季

for _, ep := range se.Episodes {
shouldMonitor := season.SeasonNumber >= maxSeason //监控最新的一季

// //如果设置下载往期剧集,则监控所有剧集。如果没有则监控未上映的剧集,考虑时差等问题留24h余量
// if in.DownloadHistoryEpisodes {
// shouldMonitor = true
Expand All @@ -167,18 +173,20 @@ func (c *Client) AddTv2Watchlist(in AddWatchlistIn) (interface{}, error) {
// }
// }

epid, err := c.db.SaveEposideDetail(&ent.Episode{
ep := ent.Episode{
SeasonNumber: seasonId,
EpisodeNumber: ep.EpisodeNumber,
Title: ep.Name,
Overview: ep.Overview,
AirDate: ep.AirDate,
Monitored: shouldMonitor,
})
}
epid, err := c.db.SaveEposideDetail(&ep)
if err != nil {
log.Errorf("save episode info error: %v", err)
continue
}
log.Debugf("success save episode %+v", ep)
epIds = append(epIds, epid)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/providers/welcome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SearchPageData
if (sp.code != 0) {
throw sp.message;
}
ref.invalidate(tvWatchlistDataProvider);
//ref.invalidate(tvWatchlistDataProvider);
} else {
var resp = await dio.post(APIs.watchlistMovieUrl, data: {
"tmdb_id": tmdbId,
Expand Down

0 comments on commit 8910478

Please sign in to comment.