diff --git a/db/const.go b/db/const.go index 607fda2..cd92b63 100644 --- a/db/const.go +++ b/db/const.go @@ -14,6 +14,7 @@ const ( SettingNfoSupportEnabled = "nfo_support_enabled" SettingAllowQiangban = "filter_qiangban" SettingEnableTmdbAdultContent = "tmdb_adult_content" + SetttingSizeLimiter = "size_limiter" ) const ( @@ -37,3 +38,14 @@ const ( type ResolutionType string const JwtSerectKey = "jwt_secrect_key" + +type SizeLimiter struct { + R720p Limiter `json:"720p"` + R1080p Limiter `json:"1080p"` + R2160p Limiter `json:"2160p"` +} + +type Limiter struct { + Max int `json:"max"` + Min int `json:"min"` +} diff --git a/db/db.go b/db/db.go index 4534289..92b1aa0 100644 --- a/db/db.go +++ b/db/db.go @@ -530,6 +530,16 @@ 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) IsEpisodeDownloadingOrDownloaded(id int) bool { + his := c.ent.History.Query().Where(history.EpisodeID(id)).AllX(context.Background()) + for _, h := range his { + if h.Status != history.StatusFail { + return true + } + } + return false +} + 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()) } @@ -602,4 +612,19 @@ func (c *Client) AddImportlist(il *ent.ImportList) error { func (c *Client) DeleteImportlist(id int) error { return c.ent.ImportList.DeleteOneID(id).Exec(context.TODO()) +} + +func (c *Client) GetSizeLimiter() (*SizeLimiter, error) { + v := c.GetSetting(SetttingSizeLimiter) + var limiter SizeLimiter + err := json.Unmarshal([]byte(v), &limiter) + return &limiter, err +} + +func (c *Client) SetSizeLimiter(limiter *SizeLimiter) error { + data, err := json.Marshal(limiter) + if err != nil { + return err + } + return c.SetSetting(SetttingSizeLimiter, string(data)) } \ No newline at end of file diff --git a/pkg/importlist/douban/douban.go b/pkg/importlist/douban/douban.go index 3aba7bf..b1c378c 100644 --- a/pkg/importlist/douban/douban.go +++ b/pkg/importlist/douban/douban.go @@ -55,7 +55,7 @@ func ParseDoulist(doulistUrl string) (*importlist.Response, error) { continue } else { n := ppp[1] - n1, err := strconv.Atoi(n) + n1, err := strconv.Atoi(strings.TrimSpace(n)) if err != nil { log.Errorf("convert year number %s to int error: %v", n, err) continue