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