6 # Set logging to debug level
7 # it should log messages showing where defaults come from
8 logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')
9 log = logging.getLogger()
11 client = musicpd.MPDClient()
12 # use MPD_HOST/MPD_PORT env var if set else
13 # test ${XDG_RUNTIME_DIR}/mpd/socket for existence
14 # fallback to localhost:6600
15 # connect support host/port argument as well
18 status = client.status()
19 if status.get('state') == 'play':
20 current_song_id = status.get('songid')
21 current_song = client.playlistid(current_song_id)[0]
22 log.info(f'Playing : {current_song.get("file")}')
23 next_song_id = status.get('nextsongid', None)
25 next_song = client.playlistid(next_song_id)[0]
26 log.info(f'Next song : {next_song.get("file")}')
28 log.info('Not playing')