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" msgctxt "#33153"
msgid "Your Emby theme media has been synced to Kodi" msgid "Your Emby theme media has been synced to Kodi"
msgstr "" msgstr ""
msgctxt "#33154"
msgid "Add libraries"
msgstr ""

View file

@ -93,6 +93,8 @@ class Events(object):
event('RepairLibrarySelection') event('RepairLibrarySelection')
elif mode == 'updatelibs': elif mode == 'updatelibs':
event('SyncLibrarySelection') event('SyncLibrarySelection')
elif mode == 'addlibs':
event('AddLibrarySelection')
elif mode == 'connect': elif mode == 'connect':
event('EmbyConnect') event('EmbyConnect')
elif mode == 'addserver': elif mode == 'addserver':
@ -152,7 +154,7 @@ def listing():
directory(label, path, artwork=artwork) directory(label, path, artwork=artwork)
elif xbmc.getCondVisibility('Window.IsActive(Videos)') and node not in ('photos', 'homevideos', 'music'): elif xbmc.getCondVisibility('Window.IsActive(Videos)') and node not in ('photos', 'homevideos', 'music'):
directory(label, path, artwork=artwork, context=context) 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) directory(label, path, artwork=artwork, context=context)
elif not xbmc.getCondVisibility('Window.IsActive(Videos) | Window.IsActive(Pictures) | Window.IsActive(Music)'): elif not xbmc.getCondVisibility('Window.IsActive(Videos) | Window.IsActive(Pictures) | Window.IsActive(Music)'):
directory(label, path, artwork=artwork) directory(label, path, artwork=artwork)
@ -173,6 +175,7 @@ def listing():
directory(_(5), "plugin://plugin.video.emby/?mode=settings", False) directory(_(5), "plugin://plugin.video.emby/?mode=settings", False)
directory(_(33054), "plugin://plugin.video.emby/?mode=adduser", False) directory(_(33054), "plugin://plugin.video.emby/?mode=adduser", False)
directory(_(33098), "plugin://plugin.video.emby/?mode=refreshboxsets", 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(_(33139), "plugin://plugin.video.emby/?mode=updatelibs", False)
directory(_(33140), "plugin://plugin.video.emby/?mode=repairlibs", False) directory(_(33140), "plugin://plugin.video.emby/?mode=repairlibs", False)
directory(_(33060), "plugin://plugin.video.emby/?mode=thememedia", 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', 'LibraryChanged', 'ServerOnline', 'SyncLibrary', 'RepairLibrary', 'RemoveLibrary',
'EmbyConnect', 'SyncLibrarySelection', 'RepairLibrarySelection', 'AddServer', 'EmbyConnect', 'SyncLibrarySelection', 'RepairLibrarySelection', 'AddServer',
'Unauthorized', 'UpdateServer', 'UserConfigurationUpdated', 'ServerRestarting', 'Unauthorized', 'UpdateServer', 'UserConfigurationUpdated', 'ServerRestarting',
'RemoveServer'): 'RemoveServer', 'AddLibrarySelection'):
return return
data = json.loads(data)[0] data = json.loads(data)[0]
@ -265,8 +265,8 @@ class Service(xbmc.Monitor):
window('emby_should_stop.bool', True) window('emby_should_stop.bool', True)
self.running = False self.running = False
elif method in ('SyncLibrarySelection', 'RepairLibrarySelection'): elif method in ('SyncLibrarySelection', 'RepairLibrarySelection', 'AddLibrarySelection'):
self.library_thread.select_libraries('SyncLibrary' if method == 'SyncLibrarySelection' else 'RepairLibrary') self.library_thread.select_libraries(method)
elif method == 'SyncLibrary': elif method == 'SyncLibrary':
libraries = data['Id'].split(',') libraries = data['Id'].split(',')

View file

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