Trending, most watched and anticipated movies and series from Trakt
With an empty search box, Movies and Series show one of Trakt's public lists: trending now, most watched this week, anticipated, popular, and for movies the US box office. [ ] switch lists, r reloads. Each entry is looked up in Radarr (tmdb:) or Sonarr (tvdb:), so it behaves like a search result: details, poster, tick when in the library, add, releases. Needs a Trakt client ID: new optional trakt.client_id setting (Config view section "Trakt", ARR_TUI_TRAKT_CLIENT_ID), masked like the API keys and checked by Test. ARR_TUI_TRAKT_URL points at another server for development. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,11 +77,18 @@ func (u UI) ShouldNotifyDownloads() bool { return u.NotifyDownloads == nil || *u
|
||||
// ShowCovers reports whether poster thumbnails are enabled.
|
||||
func (u UI) ShowCovers() bool { return u.Covers == nil || *u.Covers }
|
||||
|
||||
// Trakt holds the client ID of a Trakt API app, used for the trending,
|
||||
// most watched and anticipated lists. Optional.
|
||||
type Trakt struct {
|
||||
ClientID string `json:"client_id,omitempty"`
|
||||
}
|
||||
|
||||
// Config is the full application configuration.
|
||||
type Config struct {
|
||||
Radarr Arr `json:"radarr"`
|
||||
Sonarr Arr `json:"sonarr"`
|
||||
SABnzbd Service `json:"sabnzbd"`
|
||||
Trakt Trakt `json:"trakt"`
|
||||
UI UI `json:"ui"`
|
||||
}
|
||||
|
||||
@@ -184,12 +191,13 @@ func (c *Config) Effective(env func(string) string) (*Config, error) {
|
||||
// envVars maps the settings that can be overridden by the environment to the
|
||||
// variable that does it.
|
||||
var envVars = map[string]string{
|
||||
"radarr.url": "ARR_TUI_RADARR_URL",
|
||||
"radarr.apikey": "ARR_TUI_RADARR_APIKEY",
|
||||
"sonarr.url": "ARR_TUI_SONARR_URL",
|
||||
"sonarr.apikey": "ARR_TUI_SONARR_APIKEY",
|
||||
"sabnzbd.url": "ARR_TUI_SABNZBD_URL",
|
||||
"sabnzbd.apikey": "ARR_TUI_SABNZBD_APIKEY",
|
||||
"radarr.url": "ARR_TUI_RADARR_URL",
|
||||
"radarr.apikey": "ARR_TUI_RADARR_APIKEY",
|
||||
"sonarr.url": "ARR_TUI_SONARR_URL",
|
||||
"sonarr.apikey": "ARR_TUI_SONARR_APIKEY",
|
||||
"sabnzbd.url": "ARR_TUI_SABNZBD_URL",
|
||||
"sabnzbd.apikey": "ARR_TUI_SABNZBD_APIKEY",
|
||||
"trakt.client_id": "ARR_TUI_TRAKT_CLIENT_ID",
|
||||
}
|
||||
|
||||
// Overrides returns, for every setting that the environment currently
|
||||
@@ -253,6 +261,7 @@ func (c *Config) applyEnv(get func(string) string) {
|
||||
override(&c.Sonarr.APIKey, "ARR_TUI_SONARR_APIKEY")
|
||||
override(&c.SABnzbd.URL, "ARR_TUI_SABNZBD_URL")
|
||||
override(&c.SABnzbd.APIKey, "ARR_TUI_SABNZBD_APIKEY")
|
||||
override(&c.Trakt.ClientID, "ARR_TUI_TRAKT_CLIENT_ID")
|
||||
}
|
||||
|
||||
func (c *Config) applyDefaults() {
|
||||
@@ -262,6 +271,7 @@ func (c *Config) applyDefaults() {
|
||||
c.Radarr.URL = strings.TrimRight(c.Radarr.URL, "/")
|
||||
c.Sonarr.URL = strings.TrimRight(c.Sonarr.URL, "/")
|
||||
c.SABnzbd.URL = strings.TrimRight(c.SABnzbd.URL, "/")
|
||||
c.Trakt.ClientID = strings.TrimSpace(c.Trakt.ClientID)
|
||||
}
|
||||
|
||||
// Validate checks that every service that is set up has a usable URL and API
|
||||
|
||||
@@ -233,3 +233,15 @@ func TestCreate(t *testing.T) {
|
||||
t.Errorf("the new file must load cleanly: %v %v", warnings, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTraktClientID(t *testing.T) {
|
||||
cfg, err := Parse([]byte(`{"trakt":{"client_id":" abc "}}`))
|
||||
if err != nil || cfg.Trakt.ClientID != "abc" {
|
||||
t.Fatalf("client id %q, %v", cfg.Trakt.ClientID, err)
|
||||
}
|
||||
t.Setenv("ARR_TUI_TRAKT_CLIENT_ID", "from-env")
|
||||
cfg, _ = Parse([]byte(`{}`))
|
||||
if cfg.Trakt.ClientID != "from-env" || Overrides(os.Getenv)["trakt.client_id"] != "ARR_TUI_TRAKT_CLIENT_ID" {
|
||||
t.Errorf("env override: %q", cfg.Trakt.ClientID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user