Prep parentid change

Few other things
This commit is contained in:
angelblue05 2018-09-12 19:43:51 -05:00
parent 0478894676
commit 2deb31b294
8 changed files with 51 additions and 26 deletions

View file

@ -61,8 +61,9 @@ class Database(object):
LOG.debug("--->[ database: %s ] %s", self.db_file, id(self.conn)) LOG.debug("--->[ database: %s ] %s", self.db_file, id(self.conn))
if self.db_file == 'emby': if not window('emby_db_check.bool') and self.db_file == 'emby':
window('emby_db_check.bool', True)
emby_tables(self.cursor) emby_tables(self.cursor)
self.conn.commit() self.conn.commit()
@ -101,12 +102,18 @@ def emby_tables(cursor):
"""CREATE TABLE IF NOT EXISTS emby( """CREATE TABLE IF NOT EXISTS emby(
emby_id TEXT UNIQUE, media_folder TEXT, emby_type TEXT, media_type TEXT, emby_id TEXT UNIQUE, media_folder TEXT, emby_type TEXT, media_type TEXT,
kodi_id INTEGER, kodi_fileid INTEGER, kodi_pathid INTEGER, parent_id INTEGER, kodi_id INTEGER, kodi_fileid INTEGER, kodi_pathid INTEGER, parent_id INTEGER,
checksum INTEGER)""") checksum INTEGER, emby_parent_id TEXT)""")
cursor.execute( cursor.execute(
"""CREATE TABLE IF NOT EXISTS view( """CREATE TABLE IF NOT EXISTS view(
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT)""") view_id TEXT UNIQUE, view_name TEXT, media_type TEXT)""")
cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)") cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
columns = cursor.execute("SELECT * FROM emby")
if 'emby_parent_id' not in [description[0] for description in columns.description]:
LOG.info("Add missing column emby_parent_id")
cursor.execute("ALTER TABLE emby ADD COLUMN emby_parent_id 'TEXT'")
def reset(): def reset():
''' Reset both the emby database and the kodi database. ''' Reset both the emby database and the kodi database.

View file

@ -88,6 +88,11 @@ class EmbyDatabase():
except TypeError: except TypeError:
return return
def get_media_by_parent_id(self, *args):
self.cursor.execute(QU.get_media_by_parent_id, args)
return self.cursor.fetchall()
def remove_item(self, *args): def remove_item(self, *args):
self.cursor.execute(QU.delete_item, args) self.cursor.execute(QU.delete_item, args)

View file

@ -61,6 +61,10 @@ get_media_by_id = """ SELECT emby_type
FROM emby FROM emby
WHERE emby_id = ? WHERE emby_id = ?
""" """
get_media_by_parent_id = """ SELECT emby_id, emby_type
FROM emby
WHERE emby_parent_id = ?
"""
get_view = """ SELECT view_name, media_type get_view = """ SELECT view_name, media_type
FROM view FROM view
WHERE view_id = ? WHERE view_id = ?
@ -76,29 +80,34 @@ get_items_by_media = """ SELECT emby_id
add_reference = """ INSERT OR REPLACE INTO emby(emby_id, kodi_id, kodi_fileid, kodi_pathid, emby_type, add_reference = """ INSERT OR REPLACE INTO emby(emby_id, kodi_id, kodi_fileid, kodi_pathid, emby_type,
media_type, parent_id, checksum, media_folder) media_type, parent_id, checksum, media_folder, emby_parent_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""" """
add_reference_movie_obj = [ "{Id}","{MovieId}","{FileId}","{PathId}","Movie","movie", None,"{Checksum}","{LibraryId}" add_reference_movie_obj = [ "{Id}","{MovieId}","{FileId}","{PathId}","Movie","movie", None,"{Checksum}","{LibraryId}",
"{EmbyParentId}"
] ]
add_reference_boxset_obj = [ "{Id}","{SetId}",None,None,"BoxSet","set",None,"{Checksum}",None add_reference_boxset_obj = [ "{Id}","{SetId}",None,None,"BoxSet","set",None,"{Checksum}",None,None
] ]
add_reference_tvshow_obj = [ "{Id}","{ShowId}",None,"{PathId}","Series","tvshow",None,"{Checksum}","{LibraryId}" add_reference_tvshow_obj = [ "{Id}","{ShowId}",None,"{PathId}","Series","tvshow",None,"{Checksum}","{LibraryId}",
"{EmbyParentId}"
] ]
add_reference_season_obj = [ "{Id}","{SeasonId}",None,None,"Season","season","{ShowId}",None,None add_reference_season_obj = [ "{Id}","{SeasonId}",None,None,"Season","season","{ShowId}",None,None,None
] ]
add_reference_pool_obj = [ "{SeriesId}","{ShowId}",None,"{PathId}","Series","tvshow",None,"{Checksum}","{LibraryId}" add_reference_pool_obj = [ "{SeriesId}","{ShowId}",None,"{PathId}","Series","tvshow",None,"{Checksum}","{LibraryId}",None
] ]
add_reference_episode_obj = [ "{Id}","{EpisodeId}","{FileId}","{PathId}","Episode","episode","{SeasonId}","{Checksum}",None add_reference_episode_obj = [ "{Id}","{EpisodeId}","{FileId}","{PathId}","Episode","episode","{SeasonId}","{Checksum}",
None,"{EmbyParentId}"
] ]
add_reference_mvideo_obj = [ "{Id}","{MvideoId}","{FileId}","{PathId}","MusicVideo","musicvideo",None,"{Checksum}", add_reference_mvideo_obj = [ "{Id}","{MvideoId}","{FileId}","{PathId}","MusicVideo","musicvideo",None,"{Checksum}",
"{LibraryId}" "{LibraryId}","{EmbyParentId}"
] ]
add_reference_artist_obj = [ "{Id}","{ArtistId}",None,None,"{ArtistType}","artist",None,"{Checksum}","{LibraryId}" add_reference_artist_obj = [ "{Id}","{ArtistId}",None,None,"{ArtistType}","artist",None,"{Checksum}","{LibraryId}",
"{EmbyParentId}"
] ]
add_reference_album_obj = [ "{Id}","{AlbumId}",None,None,"MusicAlbum","album",None,"{Checksum}",None add_reference_album_obj = [ "{Id}","{AlbumId}",None,None,"MusicAlbum","album",None,"{Checksum}",None,"{EmbyParentId}"
] ]
add_reference_song_obj = [ "{Id}","{SongId}",None,"{PathId}","Audio","song","{AlbumId}","{Checksum}",None add_reference_song_obj = [ "{Id}","{SongId}",None,"{PathId}","Audio","song","{AlbumId}","{Checksum}",
None,"{EmbyParentId}"
] ]
add_view = """ INSERT OR REPLACE INTO view(view_id, view_name, media_type) add_view = """ INSERT OR REPLACE INTO view(view_id, view_name, media_type)
VALUES (?, ?, ?) VALUES (?, ?, ?)

View file

@ -203,8 +203,7 @@ def get_plugins():
def get_seasons(show_id): def get_seasons(show_id):
return shows("/%s/Seasons" % show_id, params={ return shows("/%s/Seasons" % show_id, params={
'UserId': "{UserId}", 'UserId': "{UserId}"
'Fields': basic_info()
}) })
def get_date_modified(date, parent_id, media=None): def get_date_modified(date, parent_id, media=None):

View file

@ -263,12 +263,14 @@ class Service(xbmc.Monitor):
if data.get('ServerId'): if data.get('ServerId'):
return return
LOG.info("[ UserDataChanged ] %s", data)
self.library_thread.userdata(data['UserDataList']) self.library_thread.userdata(data['UserDataList'])
elif method == 'LibraryChanged' and self.library_thread: elif method == 'LibraryChanged' and self.library_thread:
if data.get('ServerId'): if data.get('ServerId'):
return return
LOG.info("[ LibraryChanged ] %s", data)
self.library_thread.updated(data['ItemsUpdated'] + data['ItemsAdded']) self.library_thread.updated(data['ItemsUpdated'] + data['ItemsAdded'])
self.library_thread.removed(data['ItemsRemoved']) self.library_thread.removed(data['ItemsRemoved'])

View file

@ -580,12 +580,17 @@ class SortWorker(threading.Thread):
return return
media = database.get_media_by_id(item_id) try:
media = database.get_media_by_id(item_id)
if media:
self.output[media].put({'Id': item_id, 'Type': media}) self.output[media].put({'Id': item_id, 'Type': media})
else: except Exception:
LOG.info("Could not find media %s in the emby database.", item_id) items = database.get_media_by_parent_id(item_id)
if not items:
LOG.info("Could not find media %s in the emby database.", item_id)
else:
for item in items:
self.output[item[1]].put({'Id': item[0], 'Type': item[1]})
self.queue.task_done() self.queue.task_done()

View file

@ -32,16 +32,14 @@ class Setup(object):
if settings('enableTextureCache.bool'): if settings('enableTextureCache.bool'):
get_setting = JSONRPC('Settings.GetSettingValue') get_setting = JSONRPC('Settings.GetSettingValue')
enabled = self.get_web_server()
if not enabled: if not self.get_web_server():
set_setting = JSONRPC('Settings.SetSetingValue') set_setting = JSONRPC('Settings.SetSetingValue')
set_setting.execute({'setting': "services.webserverport", 'value': 50325}) set_setting.execute({'setting': "services.webserverport", 'value': 50325})
set_setting.execute({'setting': "services.webserver", 'value': True}) set_setting.execute({'setting': "services.webserver", 'value': True})
enabled = self.get_web_server()
if not enabled: if not self.get_web_server():
settings('enableTextureCache.bool', False) settings('enableTextureCache.bool', False)
dialog("ok", heading="{emby}", line1=_(33103)) dialog("ok", heading="{emby}", line1=_(33103))

View file

@ -759,7 +759,7 @@ class Views(object):
else: else:
path = self.window_path(view, node) path = self.window_path(view, node)
if node in ('browse', 'books', 'audiobooks'): if node in ('browse', 'audiobooks'):
window_path = path window_path = path
else: else:
window_path = "ActivateWindow(Videos,%s,return)" % path window_path = "ActivateWindow(Videos,%s,return)" % path