mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Prep parentid change
Few other things
This commit is contained in:
parent
0478894676
commit
2deb31b294
8 changed files with 51 additions and 26 deletions
|
@ -61,8 +61,9 @@ class Database(object):
|
|||
|
||||
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)
|
||||
self.conn.commit()
|
||||
|
||||
|
@ -101,12 +102,18 @@ def emby_tables(cursor):
|
|||
"""CREATE TABLE IF NOT EXISTS emby(
|
||||
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,
|
||||
checksum INTEGER)""")
|
||||
checksum INTEGER, emby_parent_id TEXT)""")
|
||||
cursor.execute(
|
||||
"""CREATE TABLE IF NOT EXISTS view(
|
||||
view_id TEXT UNIQUE, view_name TEXT, media_type 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():
|
||||
|
||||
''' Reset both the emby database and the kodi database.
|
||||
|
|
|
@ -88,6 +88,11 @@ class EmbyDatabase():
|
|||
except TypeError:
|
||||
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):
|
||||
self.cursor.execute(QU.delete_item, args)
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ get_media_by_id = """ SELECT emby_type
|
|||
FROM emby
|
||||
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
|
||||
FROM view
|
||||
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,
|
||||
media_type, parent_id, checksum, media_folder)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
media_type, parent_id, checksum, media_folder, emby_parent_id)
|
||||
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}",
|
||||
"{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)
|
||||
VALUES (?, ?, ?)
|
||||
|
|
|
@ -203,8 +203,7 @@ def get_plugins():
|
|||
|
||||
def get_seasons(show_id):
|
||||
return shows("/%s/Seasons" % show_id, params={
|
||||
'UserId': "{UserId}",
|
||||
'Fields': basic_info()
|
||||
'UserId': "{UserId}"
|
||||
})
|
||||
|
||||
def get_date_modified(date, parent_id, media=None):
|
||||
|
|
|
@ -263,12 +263,14 @@ class Service(xbmc.Monitor):
|
|||
if data.get('ServerId'):
|
||||
return
|
||||
|
||||
LOG.info("[ UserDataChanged ] %s", data)
|
||||
self.library_thread.userdata(data['UserDataList'])
|
||||
|
||||
elif method == 'LibraryChanged' and self.library_thread:
|
||||
if data.get('ServerId'):
|
||||
return
|
||||
|
||||
LOG.info("[ LibraryChanged ] %s", data)
|
||||
self.library_thread.updated(data['ItemsUpdated'] + data['ItemsAdded'])
|
||||
self.library_thread.removed(data['ItemsRemoved'])
|
||||
|
||||
|
|
|
@ -580,12 +580,17 @@ class SortWorker(threading.Thread):
|
|||
|
||||
return
|
||||
|
||||
media = database.get_media_by_id(item_id)
|
||||
|
||||
if media:
|
||||
try:
|
||||
media = database.get_media_by_id(item_id)
|
||||
self.output[media].put({'Id': item_id, 'Type': media})
|
||||
else:
|
||||
LOG.info("Could not find media %s in the emby database.", item_id)
|
||||
except Exception:
|
||||
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()
|
||||
|
||||
|
|
|
@ -32,16 +32,14 @@ class Setup(object):
|
|||
if settings('enableTextureCache.bool'):
|
||||
|
||||
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.execute({'setting': "services.webserverport", 'value': 50325})
|
||||
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)
|
||||
dialog("ok", heading="{emby}", line1=_(33103))
|
||||
|
|
|
@ -759,7 +759,7 @@ class Views(object):
|
|||
else:
|
||||
path = self.window_path(view, node)
|
||||
|
||||
if node in ('browse', 'books', 'audiobooks'):
|
||||
if node in ('browse', 'audiobooks'):
|
||||
window_path = path
|
||||
else:
|
||||
window_path = "ActivateWindow(Videos,%s,return)" % path
|
||||
|
|
Loading…
Reference in a new issue