diff --git a/mopidy_plex/__init__.py b/mopidy_plex/__init__.py index a61aa31..e890b01 100644 --- a/mopidy_plex/__init__.py +++ b/mopidy_plex/__init__.py @@ -27,6 +27,7 @@ def get_config_schema(self): schema['server'] = config.String() schema['username'] = config.String() schema['password'] = config.Secret() + schema['music_library_section_id'] = config.String() return schema def setup(self, registry): diff --git a/mopidy_plex/backend.py b/mopidy_plex/backend.py index dcbbce7..a6fb7c9 100644 --- a/mopidy_plex/backend.py +++ b/mopidy_plex/backend.py @@ -41,6 +41,7 @@ def __init__(self, config, audio): self.plex = self.account.resource(config['plex']['server']).connect() self.music = [s for s in self.plex.library.sections() if s.TYPE == MusicSection.TYPE][0] logger.debug('Found music section on plex server %s: %s', self.plex, self.music) + self.music_library_section_id = config['plex']['music_library_section_id'] self.uri_schemes = ['plex', ] self.library = PlexLibraryProvider(backend=self) self.playback = PlexPlaybackProvider(audio=audio, backend=self) diff --git a/mopidy_plex/ext.conf b/mopidy_plex/ext.conf index 8f4961d..20dcba9 100644 --- a/mopidy_plex/ext.conf +++ b/mopidy_plex/ext.conf @@ -3,3 +3,4 @@ enabled = true server = http://192.168.0.105:32400 username = user password = pass +music_library_section_id = 1 diff --git a/mopidy_plex/library.py b/mopidy_plex/library.py index fd254a6..1f4bac2 100644 --- a/mopidy_plex/library.py +++ b/mopidy_plex/library.py @@ -19,6 +19,7 @@ class PlexLibraryProvider(backend.LibraryProvider): def __init__(self, *args, **kwargs): super(PlexLibraryProvider, self).__init__(*args, **kwargs) self.plex = self.backend.plex + self.music_library_section_id = self.backend.music_library_section_id self._root = [] self._root.append(Ref.directory(uri='plex:album', name='Albums')) self._root.append(Ref.directory(uri='plex:artist', name='Artists')) @@ -44,7 +45,7 @@ def browse(self, uri): if uri == 'plex:album': logger.debug('self._browse_albums()') return [self._item_ref(item, 'album') for item in - plexutils.listItems(self.plex, '/library/sections/4/albums')] + plexutils.listItems(self.plex, '/'.join(['/library/sections',self.music_library_section_id,'albums']))] # a single album # uri == 'plex:album:album_id' @@ -59,7 +60,7 @@ def browse(self, uri): if uri == 'plex:artist': logger.debug('self._browse_artists()') return [self._item_ref(item, 'artist') for item in - plexutils.listItems(self.plex, '/library/sections/4/all')] + plexutils.listItems(self.plex, '/'.join(['/library/sections',self.music_library_section_id,'all']))] # a single artist # uri == 'plex:artist:artist_id'