Fix missing new artists

This commit is contained in:
angelblue05 2018-10-02 18:33:25 -05:00
parent c250457c87
commit b8ea16ed46
4 changed files with 35 additions and 18 deletions

View file

@ -135,6 +135,11 @@ class EmbyDatabase():
return self.cursor.fetchall()
def get_views_by_media(self, *args):
self.cursor.execute(QU.get_views_by_media, args)
return self.cursor.fetchall()
def get_items_by_media(self, *args):
self.cursor.execute(QU.get_items_by_media, args)

View file

@ -72,6 +72,10 @@ get_view = """ SELECT view_name, media_type
get_views = """ SELECT *
FROM view
"""
get_views_by_media = """ SELECT *
FROM view
WHERE media_type = ?
"""
get_items_by_media = """ SELECT emby_id
FROM emby
WHERE media_type = ?

View file

@ -120,8 +120,17 @@ def library_check():
ancestors = self.server['api'].get_ancestors(item['Id'])
if not ancestors:
if item['Type'] == 'MusicArtist':
try:
views = self.emby_db.get_views_by_media('music')[0]
except Exception:
return
view = {'Id': views[0], 'Name': views[1]}
else: # Grab the first music library
return
else:
for ancestor in ancestors:
if ancestor['Type'] == 'CollectionFolder':

View file

@ -193,9 +193,8 @@ class Music(KodiDb):
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
continue
else:
self.add_discography(*values(temp_obj, QU.update_discography_obj))
self.add_discography(*values(temp_obj, QU.update_discography_obj))
self.emby_db.update_parent_id(*values(temp_obj, QUEM.update_parent_album_obj))
def artist_link(self, obj):
@ -212,15 +211,13 @@ class Music(KodiDb):
try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
continue
"""
self.artist(self.server['api'].get_item(temp_obj['Id']), artist_type="AlbumArtist")
try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
except Exception as error:
LOG.error(error)
continue
"""
else:
self.update_artist_name(*values(temp_obj, QU.update_artist_name_obj))
@ -367,11 +364,12 @@ class Music(KodiDb):
try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
self.artist(self.server['api'].get_item(temp_obj['Id']))
try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
except Exception as error:
LOG.error(error)
continue
self.link(*values(temp_obj, QU.update_link_obj))
@ -399,11 +397,12 @@ class Music(KodiDb):
try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
self.artist(self.server['api'].get_item(temp_obj['Id']))
try:
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError:
except Exception as error:
LOG.error(error)
continue
self.link_song_artist(*values(temp_obj, QU.update_song_artist_obj))