mrstegeman / mpd-webthing

Turn MPD into a Web Thing
Mozilla Public License 2.0
10 stars 2 forks source link

python KeyError: 'volume' error #3

Closed novski closed 3 years ago

novski commented 3 years ago

Hi I tried your webthing an run in to a error. Is that related to my config somehow? I don't understand where status['volume'] comes from. Regards, novski

root@OpenWrt:~/mpd-webthing/python# python3 mpd-webthing.py 
Traceback (most recent call last):
  File "mpd-webthing.py", line 586, in <module>
    run_server()
  File "mpd-webthing.py", line 575, in run_server
    thing = MPDThing()
  File "mpd-webthing.py", line 135, in __init__
    Value(self.get_volume(status), self.set_volume),
  File "mpd-webthing.py", line 327, in get_volume
    return int(status['volume'])
KeyError: 'volume'
root@OpenWrt:~/mpd-webthing/python# ps | grep mpd
 6123 root     16084 S<   /usr/bin/mpd --no-daemon /etc/mpd.conf
 6135 root      1212 S    grep mpd
root@OpenWrt:~/mpd-webthing/python# cat /etc/mpd.conf
bind_to_address     "127.0.0.1"
port            "6600"

music_directory       "/root/audio/music"
playlist_directory    "/root/audio/playlists"
db_file               "/root/mpd/database"
log_file              "/root/mpd/log"
log_level             "verbose"
pid_file              "/root/mpd/pid"
state_file            "/root/mpd/state"
user                  "root"
group                 "root"

input {
    plugin "curl"
}

audio_output {
        type          "alsa"
        name          "i2s-wm8960"
        device        "hw:0,0"
        mixer_control "Master"
}
mrstegeman commented 3 years ago

It should be included in the MPD status response: https://www.musicpd.org/doc/html/protocol.html#querying-mpd-s-status

Apparently that's now deprecated, though. It looks like it should maybe be using getvol instead now.

novski commented 3 years ago

Do you think i can just replace the key in Line 327 to : return int(status['getvol'])? I think that does not work:

root@OpenWrt:~/mpd-webthing/python# vi mpd-webthing.py 
root@OpenWrt:~/mpd-webthing/python# python3 mpd-webthing.py 
Traceback (most recent call last):
  File "mpd-webthing.py", line 586, in <module>
    run_server()
  File "mpd-webthing.py", line 575, in run_server
    thing = MPDThing()
  File "mpd-webthing.py", line 135, in __init__
    Value(self.get_volume(status), self.set_volume),
  File "mpd-webthing.py", line 327, in get_volume
    return int(status['getvol'])
KeyError: 'getvol'

edit: I checked the version and let that here as background information:

root@OpenWrt:~/mpd-webthing/python# mpd --version
Music Player Daemon 0.21.25 (0.21.25)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2018 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy upnp

Storage plugins:
 local curl

Decoders plugins:
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [faad] aac
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve
 [pcm]

Filters:

Tag plugins:
 id3tag

Output plugins:
 shout null fifo pipe alsa pulse httpd recorder

Encoder plugins:
 null wave flac

Input plugins:
 file alsa curl ffmpeg mms

Playlist plugins:
 extm3u m3u pls xspf asx rss soundcloud flac cue embcue

Protocols:
 file:// alsa:// http:// https:// gopher:// rtp:// rtsp:// rtmp:// rtmpt:// rtmps:// mms:// mmsh:// mmst:// mmsu://

Other features:
 epoll iconv inotify ipv6 tcp un
root@OpenWrt:~/mpd-webthing/python# 
mrstegeman commented 3 years ago

No, it’s a separate call via the MPD API. I’ll probably work on a fix on Friday.

novski commented 3 years ago

ok. thanks. I just checked the changelog and didn't find a change on volume since 0.21.25 (my openwrt version).