Implemented playlist_deleted event
This commit is contained in:
parent
ee0f2f2a94
commit
8975e72b34
@ -36,6 +36,8 @@ Core API
|
|||||||
- Add `max_tracklist_length` config and limitation. (Fixes: :issue:`997`
|
- Add `max_tracklist_length` config and limitation. (Fixes: :issue:`997`
|
||||||
PR: :issue:`1225`)
|
PR: :issue:`1225`)
|
||||||
|
|
||||||
|
- Added ``playlist_deleted`` event (Fixes: :issue:`996`)
|
||||||
|
|
||||||
Models
|
Models
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|||||||
@ -123,6 +123,17 @@ class CoreListener(listener.Listener):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def playlist_deleted(self, uri):
|
||||||
|
"""
|
||||||
|
Called whenever a playlist is deleted.
|
||||||
|
|
||||||
|
*MAY* be implemented by actor.
|
||||||
|
|
||||||
|
:param uri: the uri of the deleted playlist
|
||||||
|
:type uri: string
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def options_changed(self):
|
def options_changed(self):
|
||||||
"""
|
"""
|
||||||
Called whenever an option is changed.
|
Called whenever an option is changed.
|
||||||
|
|||||||
@ -178,11 +178,12 @@ class PlaylistsController(object):
|
|||||||
uri_scheme = urlparse.urlparse(uri).scheme
|
uri_scheme = urlparse.urlparse(uri).scheme
|
||||||
backend = self.backends.with_playlists.get(uri_scheme, None)
|
backend = self.backends.with_playlists.get(uri_scheme, None)
|
||||||
if not backend:
|
if not backend:
|
||||||
return
|
return None # TODO: error reporting to user
|
||||||
|
|
||||||
with _backend_error_handling(backend):
|
with _backend_error_handling(backend):
|
||||||
backend.playlists.delete(uri).get()
|
backend.playlists.delete(uri).get()
|
||||||
# TODO: emit playlist changed?
|
# TODO: error detection and reporting to user
|
||||||
|
listener.CoreListener.send('playlist_deleted', uri=uri)
|
||||||
|
|
||||||
# TODO: return value?
|
# TODO: return value?
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,7 @@ class M3UPlaylistsProvider(backend.PlaylistsProvider):
|
|||||||
logger.warning(
|
logger.warning(
|
||||||
'Trying to delete missing playlist file %s', path)
|
'Trying to delete missing playlist file %s', path)
|
||||||
del self._playlists[uri]
|
del self._playlists[uri]
|
||||||
|
logger.info('Deleted playlist %s', uri)
|
||||||
else:
|
else:
|
||||||
logger.warning('Trying to delete unknown playlist %s', uri)
|
logger.warning('Trying to delete unknown playlist %s', uri)
|
||||||
|
|
||||||
|
|||||||
@ -99,10 +99,11 @@ class BackendEventsTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(send.call_args[0][0], 'playlist_changed')
|
self.assertEqual(send.call_args[0][0], 'playlist_changed')
|
||||||
|
|
||||||
@unittest.SkipTest
|
|
||||||
def test_playlists_delete_sends_playlist_deleted_event(self, send):
|
def test_playlists_delete_sends_playlist_deleted_event(self, send):
|
||||||
# TODO We should probably add a playlist_deleted event
|
playlist = self.core.playlists.create('foo').get()
|
||||||
pass
|
self.core.playlists.delete(playlist.uri).get()
|
||||||
|
|
||||||
|
self.assertEqual(send.call_args[0][0], 'playlist_deleted')
|
||||||
|
|
||||||
def test_playlists_save_sends_playlist_changed_event(self, send):
|
def test_playlists_save_sends_playlist_changed_event(self, send):
|
||||||
playlist = self.core.playlists.create('foo').get()
|
playlist = self.core.playlists.create('foo').get()
|
||||||
|
|||||||
@ -47,6 +47,9 @@ class CoreListenerTest(unittest.TestCase):
|
|||||||
def test_listener_has_default_impl_for_playlist_changed(self):
|
def test_listener_has_default_impl_for_playlist_changed(self):
|
||||||
self.listener.playlist_changed(Playlist())
|
self.listener.playlist_changed(Playlist())
|
||||||
|
|
||||||
|
def test_listener_has_default_impl_for_playlist_deleted(self):
|
||||||
|
self.listener.playlist_deleted(Playlist())
|
||||||
|
|
||||||
def test_listener_has_default_impl_for_options_changed(self):
|
def test_listener_has_default_impl_for_options_changed(self):
|
||||||
self.listener.options_changed()
|
self.listener.options_changed()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user