emby_settings.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package settings
  2. import (
  3. "github.com/ChineseSubFinder/ChineseSubFinder/pkg/types/common"
  4. )
  5. type EmbySettings struct {
  6. Enable bool `json:"enable"` // 是否启用
  7. AddressUrl string `json:"address_url"` // 内网服务器的 url
  8. APIKey string `json:"api_key"` // API key
  9. MaxRequestVideoNumber int `json:"max_request_video_number"` // 最大请求获取视频的数量
  10. SkipWatched bool `json:"skip_watched"` // 是否跳过已经观看的
  11. MoviePathsMapping map[string]string `json:"movie_paths_mapping"` // 电影目录的映射,一旦 common setting 的目录修改,需要提示用户确认映射
  12. SeriesPathsMapping map[string]string `json:"series_paths_mapping"` // 连续剧目录的映射,一旦 common setting 的目录修改,需要提示用户确认映射
  13. AutoOrManual bool `json:"auto_or_manual"` // 自动或手动模式,自动 IMDB ID 匹配,还是使用手动目录
  14. Threads int `json:"threads"` // 同时扫描的并发数
  15. }
  16. func NewEmbySettings() *EmbySettings {
  17. return &EmbySettings{
  18. MaxRequestVideoNumber: 500,
  19. MoviePathsMapping: make(map[string]string, 0),
  20. SeriesPathsMapping: make(map[string]string, 0),
  21. Threads: 4,
  22. AutoOrManual: true,
  23. }
  24. }
  25. func (e *EmbySettings) Check() {
  26. if e.MaxRequestVideoNumber < common.EmbyApiGetItemsLimitMin ||
  27. e.MaxRequestVideoNumber > common.EmbyApiGetItemsLimitMax {
  28. e.MaxRequestVideoNumber = common.EmbyApiGetItemsLimitMin
  29. }
  30. if e.Threads < 1 || e.Threads > 6 {
  31. e.Threads = 6
  32. }
  33. }