don?t crash on stored playlists

This commit is contained in:
coderkun 2013-03-16 00:43:58 +01:00
commit 5384548dc1

21
mcg.py
View file

@ -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)