mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Update database commit
This commit is contained in:
parent
d0ea742904
commit
11af93ccc2
2 changed files with 22 additions and 26 deletions
|
@ -2,19 +2,18 @@
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
|
|
||||||
import utils
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
log = logging.getLogger("EMBY."+__name__)
|
||||||
KODI = xbmc.getInfoLabel('System.BuildVersion')[:2]
|
KODI = xbmc.getInfoLabel('System.BuildVersion')[:2]
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
|
||||||
def video_database():
|
def video_database():
|
||||||
|
|
||||||
db_version = {
|
db_version = {
|
||||||
|
@ -56,15 +55,13 @@ class DatabaseConn(object):
|
||||||
database_file can be custom: emby, texture, music, video, custom like :memory: or path
|
database_file can be custom: emby, texture, music, video, custom like :memory: or path
|
||||||
commit_mode set to None to autocommit (isolation_level). See python documentation.
|
commit_mode set to None to autocommit (isolation_level). See python documentation.
|
||||||
"""
|
"""
|
||||||
self.log = utils.Logging('Database').log
|
|
||||||
|
|
||||||
self.db_file = database_file
|
self.db_file = database_file
|
||||||
self.commit_mode = commit_mode
|
self.commit_mode = commit_mode
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
# Open the connection
|
# Open the connection
|
||||||
self.path = self._SQL(self.db_file)
|
self.path = self._SQL(self.db_file)
|
||||||
self.log("Opening database: %s" % self.path, 1)
|
log.warn("opening database: %s", self.path)
|
||||||
self.conn = sqlite3.connect(self.path, isolation_level=self.commit_mode, timeout=20)
|
self.conn = sqlite3.connect(self.path, isolation_level=self.commit_mode, timeout=20)
|
||||||
return self.conn
|
return self.conn
|
||||||
|
|
||||||
|
@ -85,16 +82,16 @@ class DatabaseConn(object):
|
||||||
# Close the connection
|
# Close the connection
|
||||||
if exc_type is not None:
|
if exc_type is not None:
|
||||||
# Errors were raised in the with statement
|
# Errors were raised in the with statement
|
||||||
self.log("Type: %s Value: %s Traceback: %s" % (exc_type, exc_val, exc_tb), -1)
|
log.error("rollback: Type: %s Value: %s", exc_type, exc_val)
|
||||||
self.conn.rollback()
|
self.conn.rollback()
|
||||||
|
|
||||||
elif self.commit_mode is not None:
|
elif self.commit_mode is not None:
|
||||||
self.log("Commit: %s" % self.path, 1)
|
log.warn("commit: %s", self.path)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
def dbquery(query, connection=None, conn_type=None, *args):
|
def query(execute_query, connection=None, conn_type=None, *args):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
connection is sqlite.connect
|
connection is sqlite.connect
|
||||||
|
|
|
@ -12,6 +12,7 @@ import xbmcgui
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
import api
|
import api
|
||||||
|
import database
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import downloadutils
|
import downloadutils
|
||||||
|
@ -55,6 +56,7 @@ class LibrarySync(threading.Thread):
|
||||||
self.monitor = xbmc.Monitor()
|
self.monitor = xbmc.Monitor()
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
|
self.database = database.DatabaseConn
|
||||||
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
||||||
self.user = userclient.UserClient()
|
self.user = userclient.UserClient()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
@ -746,6 +748,7 @@ class LibrarySync(threading.Thread):
|
||||||
# Received userconfig update
|
# Received userconfig update
|
||||||
self.refresh_views = False
|
self.refresh_views = False
|
||||||
self.maintainViews(embycursor, kodicursor)
|
self.maintainViews(embycursor, kodicursor)
|
||||||
|
embycursor.commit()
|
||||||
self.forceLibraryUpdate = True
|
self.forceLibraryUpdate = True
|
||||||
update_embydb = True
|
update_embydb = True
|
||||||
|
|
||||||
|
@ -843,10 +846,9 @@ class LibrarySync(threading.Thread):
|
||||||
# Database out of date.
|
# Database out of date.
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
def _verify_emby_database(self):
|
||||||
def _verify_emby_database(cls):
|
|
||||||
# Create the tables for the emby database
|
# Create the tables for the emby database
|
||||||
conn = utils.kodiSQL('emby')
|
with self.database('emby') as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
# emby, view, version
|
# emby, view, version
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
|
@ -859,9 +861,6 @@ class LibrarySync(threading.Thread):
|
||||||
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT, kodi_tagid INTEGER)""")
|
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT, kodi_tagid INTEGER)""")
|
||||||
cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
|
cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue