File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ SYSTEM_URL=
1717SYSTEM_USERNAME =
1818# Password for the user (required for subsonic, recommended for plex)
1919SYSTEM_PASSWORD =
20+ # Optional admin username for systems like Navidrome/Subsonic (used only for triggering library scans)
21+ # ADMIN_SYSTEM_USERNAME=
22+ # Optional admin password for systems like Navidrome/Subsonic (used only for triggering library scans)
23+ # ADMIN_SYSTEM_PASSWORD=
2024# API Key from your media system (required for emby and jellyfin, optional for plex)
2125API_KEY =
2226# Name of the music library in your system (emby, jellyfin, plex)
Original file line number Diff line number Diff line change @@ -158,8 +158,22 @@ func (c *Subsonic) SearchSongs(tracks []*models.Track) error {
158158}
159159
160160func (c * Subsonic ) RefreshLibrary () error {
161+ if c .Cfg .AdminCreds .User != "" && c .Cfg .AdminCreds .Password != "" {
162+ adminCfg := c .Cfg
163+ adminCfg .Creds = config.Credentials {User : c .Cfg .AdminCreds .User , Password : c .Cfg .AdminCreds .Password }
164+ adminClient := NewSubsonic (adminCfg , c .HttpClient )
165+
166+ if err := adminClient .GetAuth (); err != nil {
167+ return err
168+ }
169+ return adminClient .startScan ()
170+ }
171+
172+ return c .startScan ()
173+ }
174+
175+ func (c * Subsonic ) startScan () error {
161176 reqParam := "startScan?f=json"
162-
163177 if _ , err := c .subsonicRequest (reqParam ); err != nil {
164178 return err
165179 }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ type ClientConfig struct {
4949 Sleep int `env:"SLEEP" env-default:"2"`
5050 HTTPTimeout int `env:"CLIENT_HTTP_TIMEOUT" env-default:"10"`
5151 Creds Credentials
52+ AdminCreds AdminCredentials
5253 Subsonic SubsonicConfig
5354}
5455
@@ -61,6 +62,11 @@ type Credentials struct {
6162 Salt string
6263}
6364
65+ type AdminCredentials struct {
66+ User string `env:"ADMIN_SYSTEM_USERNAME"`
67+ Password string `env:"ADMIN_SYSTEM_PASSWORD"`
68+ }
69+
6470
6571type SubsonicConfig struct {
6672 Version string `env:"SUBSONIC_VERSION" env-default:"1.16.1"`
You can’t perform that action at this time.
0 commit comments