feat: add season package download ability

This commit is contained in:
Simon Ding
2024-07-20 12:23:26 +08:00
parent 7dead9b2ac
commit 72600aff9a
9 changed files with 409 additions and 102 deletions

View File

@@ -175,14 +175,14 @@ func (c *Client) GetMediaDetails(id int) *MediaDetails {
var md = &MediaDetails{
Media: se,
}
if se.MediaType == media.MediaTypeTv {
ep, err := se.QueryEpisodes().All(context.Background())
if err != nil {
log.Errorf("get episodes %d: %v", id, err)
return nil
}
md.Episodes = ep
ep, err := se.QueryEpisodes().All(context.Background())
if err != nil {
log.Errorf("get episodes %d: %v", id, err)
return nil
}
md.Episodes = ep
return md
}
@@ -325,7 +325,6 @@ func (c *Client) AddStorage(st *StorageInfo) error {
st.Settings["movie_path"] += "/"
}
data, err := json.Marshal(st.Settings)
if err != nil {
return errors.Wrap(err, "json marshal")
@@ -477,6 +476,10 @@ func (c *Client) SetEpisodeStatus(id int, status episode.Status) error {
return c.ent.Episode.Update().Where(episode.ID(id)).SetStatus(status).Exec(context.TODO())
}
func (c *Client) SetSeasonAllEpisodeStatus(mediaID, seasonNum int, status episode.Status) error {
return c.ent.Episode.Update().Where(episode.MediaID(mediaID), episode.SeasonNumber(seasonNum)).SetStatus(status).Exec(context.TODO())
}
func (c *Client) TmdbIdInWatchlist(tmdb_id int) bool {
return c.ent.Media.Query().Where(media.TmdbID(tmdb_id)).CountX(context.TODO()) > 0
}
}