Made the mpd backend a bit more resiliant

This commit is contained in:
Fabio Manganiello 2019-01-10 01:28:12 +01:00
parent 6150e07fc9
commit c1b05226a9
3 changed files with 13 additions and 5 deletions

View file

@ -230,6 +230,10 @@ $(document).ready(function() {
}; };
var updatePlaylist = function(tracks) { var updatePlaylist = function(tracks) {
if (tracks == null) {
return;
}
var $playlistContent = $('#playlist-content'); var $playlistContent = $('#playlist-content');
$playlistContent.find('.playlist-track').remove(); $playlistContent.find('.playlist-track').remove();

View file

@ -66,10 +66,11 @@ class MusicMpdBackend(Backend):
state = status['state'].lower() state = status['state'].lower()
playlist = status['playlist'] playlist = status['playlist']
success = True success = True
except StopIteration:
pass
except Exception as e: except Exception as e:
self.logger.debug(e) self.logger.debug(e)
if not state: state = last_state
if not playlist: playlist = last_playlist
if not track: track = last_track
finally: finally:
time.sleep(self.poll_seconds) time.sleep(self.poll_seconds)
@ -83,8 +84,11 @@ class MusicMpdBackend(Backend):
if playlist != last_playlist: if playlist != last_playlist:
if last_playlist: if last_playlist:
changes = plugin.plchanges(last_playlist).output # XXX plchanges can become heavy with big playlists,
self.bus.post(PlaylistChangeEvent(changes=changes)) # PlaylistChangeEvent temporarily disabled
# changes = plugin.plchanges(last_playlist).output
# self.bus.post(PlaylistChangeEvent(changes=changes))
self.bus.post(PlaylistChangeEvent())
last_playlist = playlist last_playlist = playlist
if state == 'play' and track != last_track: if state == 'play' and track != last_track:

View file

@ -93,7 +93,7 @@ class PlaylistChangeEvent(MusicEvent):
Event fired upon playlist change Event fired upon playlist change
""" """
def __init__(self, changes, status=None, track=None, *args, **kwargs): def __init__(self, changes=None, status=None, track=None, *args, **kwargs):
""" """
:param changes: List with the tracks being added or removed :param changes: List with the tracks being added or removed
:type changes: list :type changes: list