feat: support prowlarr connection

This commit is contained in:
Simon Ding
2024-10-20 16:21:58 +08:00
parent 0e6465593b
commit b317636a8a
15 changed files with 281 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ const (
SetttingSizeLimiter = "size_limiter"
SettingTvNamingFormat = "tv_naming_format"
SettingMovieNamingFormat = "movie_naming_format"
SettingProwlarrInfo = "prowlarr_info"
)
const (
@@ -60,3 +61,8 @@ type Limiter struct {
Max int `json:"max"`
Min int `json:"min"`
}
type ProwlarrSetting struct {
ApiKey string `json:"api_key"`
URL string `json:"url"`
}

View File

@@ -660,3 +660,24 @@ func (c *Client) CleanAllDanglingEpisodes() error {
func (c *Client) AddBlacklistItem(item *ent.Blacklist) error {
return c.ent.Blacklist.Create().SetType(item.Type).SetValue(item.Value).SetNotes(item.Notes).Exec(context.Background())
}
func (c *Client) GetProwlarrSetting() (*ProwlarrSetting, error) {
s := c.GetSetting(SettingProwlarrInfo)
if s == "" {
return nil, errors.New("prowlarr setting not set")
}
var se ProwlarrSetting
if err := json.Unmarshal([]byte(s), &se); err != nil {
return nil, err
}
return &se, nil
}
func (c *Client) SaveProwlarrSetting(se *ProwlarrSetting) error {
data, err := json.Marshal(se)
if err != nil {
return err
}
return c.SetSetting(SettingProwlarrInfo, string(data))
}