Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func (c *Client) systemSetup() error {
if err := c.API.GetAuth(); err != nil {
return err
}

}

if err := c.API.AddHeader(); err != nil {
Expand Down
19 changes: 18 additions & 1 deletion src/client/plex.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (c *Plex) GetAuth() error { // Get user token from plex
return nil
}
func (c *Plex) GetLibrary() error {
if c.Cfg.AdminCreds.User != "" && c.Cfg.AdminCreds.Password != "" {
if (c.Cfg.AdminCreds.User != "" && c.Cfg.AdminCreds.Password != "") {
adminCfg := c.Cfg
adminCfg.Creds = config.Credentials{
User: c.Cfg.AdminCreds.User,
Expand All @@ -304,6 +304,23 @@ func (c *Plex) GetLibrary() error {
}
c.LibraryID = c.AdminClient.LibraryID

return err
} else if (c.Cfg.AdminCreds.APIKey != "") {
adminCfg := c.Cfg
adminCfg.Creds = config.Credentials{
APIKey: c.Cfg.AdminCreds.APIKey,
}

c.AdminClient = NewPlex(adminCfg, c.HttpClient)
if err := c.AdminClient.AddHeader(); err != nil {
return err
}
err := c.AdminClient.getLibraryRequest()
if err != nil {
return err
}
c.LibraryID = c.AdminClient.LibraryID

return err
}
return c.getLibraryRequest()
Expand Down
1 change: 1 addition & 0 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Credentials struct {
}

type AdminCredentials struct {
APIKey string `env:"ADMIN_API_KEY"`
User string `env:"ADMIN_SYSTEM_USERNAME"`
Password string `env:"ADMIN_SYSTEM_PASSWORD"`
}
Expand Down
9 changes: 9 additions & 0 deletions src/web/backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,18 @@ func (s *Server) handleWizardStep2(w http.ResponseWriter, r *http.Request) {
Password string `json:"password"`
PlaylistDir string `json:"playlist_dir"`
Sleep string `json:"sleep"`
AdminAPIKey string `json:"admin_api_key"`
AdminSystemUsername string `json:"admin_system_username"`
AdminSystemPassword string `json:"admin_system_password"`

PublicPlaylist bool `json:"public_playlist"`
}

if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
http.Error(w, "invalid JSON: "+err.Error(), http.StatusBadRequest)
return
}

if body.System == "" {
http.Error(w, "system is required", http.StatusBadRequest)
return
Expand All @@ -717,6 +723,9 @@ func (s *Server) handleWizardStep2(w http.ResponseWriter, r *http.Request) {
"PLAYLIST_DIR": body.PlaylistDir,
"SLEEP": body.Sleep,
"PUBLIC_PLAYLIST": publicPlaylist,
"ADMIN_SYSTEM_USERNAME": body.AdminSystemUsername,
"ADMIN_SYSTEM_PASSWORD": body.AdminSystemPassword,
"ADMIN_SYSTEM_APIKEY": body.AdminAPIKey,
}

if err := updateEnvKeys(s.cfg.WebEnvPath, updates, web.SampleEnv); err != nil {
Expand Down
Loading
Loading