mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Fix libraries being wiped
Catch errors to prevent false positive
This commit is contained in:
parent
753b441b5b
commit
bf0ebbc487
1 changed files with 16 additions and 10 deletions
|
@ -169,9 +169,7 @@ class Views(object):
|
||||||
libraries = self.server['api'].get_media_folders()['Items']
|
libraries = self.server['api'].get_media_folders()['Items']
|
||||||
views = self.server['api'].get_views()['Items']
|
views = self.server['api'].get_views()['Items']
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.error("Unable to process libraries: %s", error)
|
raise IndexError("Unable to retrieve libraries: %s" % error)
|
||||||
|
|
||||||
return []
|
|
||||||
|
|
||||||
libraries.extend([x for x in views if x['Id'] not in [y['Id'] for y in libraries]])
|
libraries.extend([x for x in views if x['Id'] not in [y['Id'] for y in libraries]])
|
||||||
|
|
||||||
|
@ -179,14 +177,21 @@ class Views(object):
|
||||||
|
|
||||||
def get_views(self):
|
def get_views(self):
|
||||||
|
|
||||||
''' Get the media folders. Add or remove them.
|
''' Get the media folders. Add or remove them. Do not proceed if issue getting libraries.
|
||||||
'''
|
'''
|
||||||
media = {
|
media = {
|
||||||
'movies': "Movie",
|
'movies': "Movie",
|
||||||
'tvshows': "Series",
|
'tvshows': "Series",
|
||||||
'musicvideos': "MusicVideo"
|
'musicvideos': "MusicVideo"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
libraries = self.get_libraries()
|
libraries = self.get_libraries()
|
||||||
|
except IndexError as error:
|
||||||
|
LOG.error(error)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
self.sync['SortedViews'] = [x['Id'] for x in libraries]
|
self.sync['SortedViews'] = [x['Id'] for x in libraries]
|
||||||
|
|
||||||
for library in libraries:
|
for library in libraries:
|
||||||
|
@ -684,6 +689,11 @@ class Views(object):
|
||||||
index = 0
|
index = 0
|
||||||
windex = 0
|
windex = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.media_folders = self.get_libraries()
|
||||||
|
except IndexError as error:
|
||||||
|
LOG.error(error)
|
||||||
|
|
||||||
for library in (libraries or []):
|
for library in (libraries or []):
|
||||||
view = {'Id': library[0], 'Name': library[1], 'Tag': library[1], 'Media': library[2]}
|
view = {'Id': library[0], 'Name': library[1], 'Tag': library[1], 'Media': library[2]}
|
||||||
|
|
||||||
|
@ -842,11 +852,7 @@ class Views(object):
|
||||||
if not self.server['connected']:
|
if not self.server['connected']:
|
||||||
window('%s.artwork' % prop, clear=True)
|
window('%s.artwork' % prop, clear=True)
|
||||||
|
|
||||||
elif self.server['connected']:
|
elif self.server['connected'] and self.media_folders is not None:
|
||||||
|
|
||||||
if self.media_folders is None:
|
|
||||||
self.media_folders = self.get_libraries()
|
|
||||||
|
|
||||||
for library in self.media_folders:
|
for library in self.media_folders:
|
||||||
|
|
||||||
if library['Id'] == view_id and 'Primary' in library.get('ImageTags', {}):
|
if library['Id'] == view_id and 'Primary' in library.get('ImageTags', {}):
|
||||||
|
|
Loading…
Reference in a new issue