PlaylistURIS uses established mpd connection
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Marvin Preuss 2021-08-25 09:45:51 +02:00
parent 05a63554c5
commit 40071a52f9
2 changed files with 3 additions and 8 deletions

View File

@ -48,12 +48,7 @@ func Conn() (*mpd.Client, error) {
}
// PlaylistURIS extracts uris from MPD playlist.
func PlaylistURIS() ([]string, error) {
m, err := Conn()
if err != nil {
return nil, fmt.Errorf("could not connect to MPD server :%w", err)
}
func PlaylistURIS(m *mpd.Client) ([]string, error) {
attrs, err := m.PlaylistInfo(-1, -1)
if err != nil {
return nil, fmt.Errorf("could not get playlist: %w", err)
@ -129,7 +124,7 @@ func Play(logger zerolog.Logger, rfid string, name string, uris []string) error
// Getting playlist uris from MPD server.
// This is needed to identify the right metric to use.
mpdURIS, err := PlaylistURIS()
mpdURIS, err := PlaylistURIS(m)
if err != nil {
metrics.BoxErrors.Inc()

View File

@ -34,7 +34,7 @@ func Run() {
return
}
uris, err := mpc.PlaylistURIS()
uris, err := mpc.PlaylistURIS(m)
if err != nil {
log.Error().Err(err).Msg("could not get playlist uris")
metrics.BoxErrors.Inc()