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 xbmc
|
||||
|
||||
import utils
|
||||
|
||||
#################################################################################################
|
||||
|
||||
log = logging.getLogger("EMBY."+__name__)
|
||||
KODI = xbmc.getInfoLabel('System.BuildVersion')[:2]
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
def video_database():
|
||||
|
||||
db_version = {
|
||||
|
@ -56,15 +55,13 @@ class DatabaseConn(object):
|
|||
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.
|
||||
"""
|
||||
self.log = utils.Logging('Database').log
|
||||
|
||||
self.db_file = database_file
|
||||
self.commit_mode = commit_mode
|
||||
|
||||
def __enter__(self):
|
||||
# Open the connection
|
||||
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)
|
||||
return self.conn
|
||||
|
||||
|
@ -85,16 +82,16 @@ class DatabaseConn(object):
|
|||
# Close the connection
|
||||
if exc_type is not None:
|
||||
# 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()
|
||||
|
||||
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.close()
|
||||
|
||||
def dbquery(query, connection=None, conn_type=None, *args):
|
||||
def query(execute_query, connection=None, conn_type=None, *args):
|
||||
|
||||
"""
|
||||
connection is sqlite.connect
|
||||
|
|
|
@ -12,6 +12,7 @@ import xbmcgui
|
|||
import xbmcvfs
|
||||
|
||||
import api
|
||||
import database
|
||||
import utils
|
||||
import clientinfo
|
||||
import downloadutils
|
||||
|
@ -55,6 +56,7 @@ class LibrarySync(threading.Thread):
|
|||
self.monitor = xbmc.Monitor()
|
||||
|
||||
self.clientInfo = clientinfo.ClientInfo()
|
||||
self.database = database.DatabaseConn
|
||||
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
||||
self.user = userclient.UserClient()
|
||||
self.emby = embyserver.Read_EmbyServer()
|
||||
|
@ -746,6 +748,7 @@ class LibrarySync(threading.Thread):
|
|||
# Received userconfig update
|
||||
self.refresh_views = False
|
||||
self.maintainViews(embycursor, kodicursor)
|
||||
embycursor.commit()
|
||||
self.forceLibraryUpdate = True
|
||||
update_embydb = True
|
||||
|
||||
|
@ -843,10 +846,9 @@ class LibrarySync(threading.Thread):
|
|||
# Database out of date.
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def _verify_emby_database(cls):
|
||||
def _verify_emby_database(self):
|
||||
# Create the tables for the emby database
|
||||
conn = utils.kodiSQL('emby')
|
||||
with self.database('emby') as conn:
|
||||
cursor = conn.cursor()
|
||||
# emby, view, version
|
||||
cursor.execute(
|
||||
|
@ -859,9 +861,6 @@ class LibrarySync(threading.Thread):
|
|||
view_id TEXT UNIQUE, view_name TEXT, media_type TEXT, kodi_tagid INTEGER)""")
|
||||
cursor.execute("CREATE TABLE IF NOT EXISTS version(idVersion TEXT)")
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
|
||||
def run(self):
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue