PlaylistURIS uses established mpd connection
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
05a63554c5
commit
40071a52f9
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user