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() 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): def get_items_by_media(self, *args):
self.cursor.execute(QU.get_items_by_media, 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 * get_views = """ SELECT *
FROM view FROM view
""" """
get_views_by_media = """ SELECT *
FROM view
WHERE media_type = ?
"""
get_items_by_media = """ SELECT emby_id get_items_by_media = """ SELECT emby_id
FROM emby FROM emby
WHERE media_type = ? WHERE media_type = ?

View file

@ -118,17 +118,26 @@ def library_check():
if view is None: if view is None:
ancestors = self.server['api'].get_ancestors(item['Id']) ancestors = self.server['api'].get_ancestors(item['Id'])
if not ancestors: if not ancestors:
return if item['Type'] == 'MusicArtist':
for ancestor in ancestors: try:
if ancestor['Type'] == 'CollectionFolder': views = self.emby_db.get_views_by_media('music')[0]
except Exception:
return
view = self.emby_db.get_view_name(ancestor['Id']) view = {'Id': views[0], 'Name': views[1]}
view = {'Id': None, 'Name': None} if view is None else {'Name': ancestor['Name'], 'Id': ancestor['Id']} else: # Grab the first music library
return
else:
for ancestor in ancestors:
if ancestor['Type'] == 'CollectionFolder':
break view = self.emby_db.get_view_name(ancestor['Id'])
view = {'Id': None, 'Name': None} if view is None else {'Name': ancestor['Name'], 'Id': ancestor['Id']}
break
if view['Id'] not in [x.replace('Mixed:', "") for x in sync['Whitelist'] + sync['Libraries']]: if view['Id'] not in [x.replace('Mixed:', "") for x in sync['Whitelist'] + sync['Libraries']]:
LOG.info("Library %s is not synced. Skip update.", view['Id']) LOG.info("Library %s is not synced. Skip update.", view['Id'])

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] temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError: except TypeError:
continue 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)) self.emby_db.update_parent_id(*values(temp_obj, QUEM.update_parent_album_obj))
def artist_link(self, obj): def artist_link(self, obj):
@ -212,15 +211,13 @@ class Music(KodiDb):
try: try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError: except TypeError:
continue
"""
self.artist(self.server['api'].get_item(temp_obj['Id']), artist_type="AlbumArtist")
try: 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] 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 continue
"""
else: else:
self.update_artist_name(*values(temp_obj, QU.update_artist_name_obj)) self.update_artist_name(*values(temp_obj, QU.update_artist_name_obj))
@ -367,11 +364,12 @@ class Music(KodiDb):
try: try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError: except TypeError:
self.artist(self.server['api'].get_item(temp_obj['Id']))
try: 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] 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 continue
self.link(*values(temp_obj, QU.update_link_obj)) self.link(*values(temp_obj, QU.update_link_obj))
@ -399,11 +397,12 @@ class Music(KodiDb):
try: try:
temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0] temp_obj['ArtistId'] = self.emby_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
except TypeError: except TypeError:
self.artist(self.server['api'].get_item(temp_obj['Id']))
try: 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] 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 continue
self.link_song_artist(*values(temp_obj, QU.update_song_artist_obj)) self.link_song_artist(*values(temp_obj, QU.update_song_artist_obj))