From 5384548dc138212c3e64a9b4c245c20095e1a95d Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 16 Mar 2013 00:43:58 +0100 Subject: [PATCH] don?t crash on stored playlists --- mcg.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mcg.py b/mcg.py index a9813ae..c9da5fa 100644 --- a/mcg.py +++ b/mcg.py @@ -267,15 +267,18 @@ class MCGClient(MCGBase, mpd.MPDClient): album = None pos = None if song: - hash = MCGAlbum.hash(song['album'], song['date']) - if hash in self._albums: - album = self._albums[hash] - pos = song['track'] - if type(pos) is list: - pos = pos[0] - if '/' in pos: - pos = pos[0: pos.index('/')] - pos = int(pos) - 1 + try: + hash = MCGAlbum.hash(song['album'], song['date']) + if hash in self._albums: + album = self._albums[hash] + pos = song['track'] + if type(pos) is list: + pos = pos[0] + if '/' in pos: + pos = pos[0: pos.index('/')] + pos = int(pos) - 1 + except KeyError: + pass self._state = state self._callback(MCGClient.SIGNAL_STATUS, state, album, pos, volume, error)