Add libraries option

Display audiobooks under music
This commit is contained in:
angelblue05 2018-09-08 03:11:44 -05:00
parent 77c005465a
commit 71eea37448
4 changed files with 29 additions and 9 deletions

View File

@ -745,3 +745,7 @@ msgstr ""
msgctxt "#33153"
msgid "Your Emby theme media has been synced to Kodi"
msgstr ""
msgctxt "#33154"
msgid "Add libraries"
msgstr ""

View File

@ -93,6 +93,8 @@ class Events(object):
event('RepairLibrarySelection')
elif mode == 'updatelibs':
event('SyncLibrarySelection')
elif mode == 'addlibs':
event('AddLibrarySelection')
elif mode == 'connect':
event('EmbyConnect')
elif mode == 'addserver':
@ -152,7 +154,7 @@ def listing():
directory(label, path, artwork=artwork)
elif xbmc.getCondVisibility('Window.IsActive(Videos)') and node not in ('photos', 'homevideos', 'music'):
directory(label, path, artwork=artwork, context=context)
elif xbmc.getCondVisibility('Window.IsActive(Music)') and node == 'music':
elif xbmc.getCondVisibility('Window.IsActive(Music)') and node in ('music', 'books', 'audiobooks'):
directory(label, path, artwork=artwork, context=context)
elif not xbmc.getCondVisibility('Window.IsActive(Videos) | Window.IsActive(Pictures) | Window.IsActive(Music)'):
directory(label, path, artwork=artwork)
@ -173,6 +175,7 @@ def listing():
directory(_(5), "plugin://plugin.video.emby/?mode=settings", False)
directory(_(33054), "plugin://plugin.video.emby/?mode=adduser", False)
directory(_(33098), "plugin://plugin.video.emby/?mode=refreshboxsets", False)
directory(_(33154), "plugin://plugin.video.emby/?mode=addlibs", False)
directory(_(33139), "plugin://plugin.video.emby/?mode=updatelibs", False)
directory(_(33140), "plugin://plugin.video.emby/?mode=repairlibs", False)
directory(_(33060), "plugin://plugin.video.emby/?mode=thememedia", False)

View File

@ -171,7 +171,7 @@ class Service(xbmc.Monitor):
'LibraryChanged', 'ServerOnline', 'SyncLibrary', 'RepairLibrary', 'RemoveLibrary',
'EmbyConnect', 'SyncLibrarySelection', 'RepairLibrarySelection', 'AddServer',
'Unauthorized', 'UpdateServer', 'UserConfigurationUpdated', 'ServerRestarting',
'RemoveServer'):
'RemoveServer', 'AddLibrarySelection'):
return
data = json.loads(data)[0]
@ -265,8 +265,8 @@ class Service(xbmc.Monitor):
window('emby_should_stop.bool', True)
self.running = False
elif method in ('SyncLibrarySelection', 'RepairLibrarySelection'):
self.library_thread.select_libraries('SyncLibrary' if method == 'SyncLibrarySelection' else 'RepairLibrary')
elif method in ('SyncLibrarySelection', 'RepairLibrarySelection', 'AddLibrarySelection'):
self.library_thread.select_libraries(method)
elif method == 'SyncLibrary':
libraries = data['Id'].split(',')

View File

@ -298,17 +298,30 @@ class Library(threading.Thread):
''' Select from libraries synced. Either update or repair libraries.
Send event back to service.py
'''
mode = mode or 'SyncLibrary'
modes = {
'SyncLibrarySelection': 'SyncLibrary',
'RepairLibrarySelection': 'RepairLibrary',
'AddLibrarySelection': 'SyncLibrary'
}
sync = get_sync()
libraries = []
with Database('emby') as embydb:
db = emby_db.EmbyDatabase(embydb.cursor)
if mode in ('SyncLibrarySelection', 'RepairLibrarySelection'):
for library in sync['Whitelist']:
name = db.get_view_name(library.replace('Mixed:', ""))
libraries.append({'Id': library, 'Name': name})
else:
available = [x for x in sync['SortedViews'] if x not in [y.replace('Mixed:', "") for y in sync['Whitelist']]]
for library in available:
name, media = db.get_view(library)
if media in ('movies', 'tvshows', 'musicvideos', 'mixed', 'music'):
libraries.append({'Id': library, 'Name': name})
choices = [x['Name'] for x in libraries]
choices.insert(0, _(33121))
@ -327,7 +340,7 @@ class Library(threading.Thread):
library = libraries[x - 1]
selected_libraries.append(library['Id'])
event(mode, {'Id': ','.join([libraries[x - 1]['Id'] for x in selection])})
event(modes[mode], {'Id': ','.join([libraries[x - 1]['Id'] for x in selection])})
def add_library(self, library_id):