local: Add browse support to local library interface

This commit is contained in:
Thomas Adamcik 2014-01-09 22:58:13 +01:00
parent 3e3f59c1d0
commit 816d047a09
3 changed files with 17 additions and 0 deletions

View File

@ -64,6 +64,15 @@ class Library(object):
def __init__(self, config):
self._config = config
def browse(self, path):
"""
Browse directories and tracks at the given path.
:param string path: path to browse or None for root.
:rtype: List of :class:`~mopidy.models.Ref` tracks and directories.
"""
raise NotImplementedError
def load(self):
"""
(Re)load any tracks stored in memory, if any, otherwise just return

View File

@ -50,6 +50,9 @@ class JsonLibrary(local.Library):
self._json_file = os.path.join(
config['local']['data_dir'], b'library.json.gz')
def browse(self, path):
return []
def load(self):
logger.debug('Loading json library from %s', self._json_file)
library = load_library(self._json_file)

View File

@ -17,6 +17,11 @@ class LocalLibraryProvider(backend.LibraryProvider):
self._library = library
self.refresh()
def browse(self, path):
if not self._library:
return []
return self._library.browse(path)
def refresh(self, uri=None):
if not self._library:
return 0