From 816d047a0999cda44155d4d1a0d999f208f358f2 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Thu, 9 Jan 2014 22:58:13 +0100 Subject: [PATCH] local: Add browse support to local library interface --- mopidy/local/__init__.py | 9 +++++++++ mopidy/local/json.py | 3 +++ mopidy/local/library.py | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/mopidy/local/__init__.py b/mopidy/local/__init__.py index 5a46283d..8b4a8b1f 100644 --- a/mopidy/local/__init__.py +++ b/mopidy/local/__init__.py @@ -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 diff --git a/mopidy/local/json.py b/mopidy/local/json.py index f81d6915..8404f0a4 100644 --- a/mopidy/local/json.py +++ b/mopidy/local/json.py @@ -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) diff --git a/mopidy/local/library.py b/mopidy/local/library.py index 13d46979..dc068457 100644 --- a/mopidy/local/library.py +++ b/mopidy/local/library.py @@ -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