mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 09:46:11 +00:00
support for isengard sqlite and **experimental** mysql support
This commit is contained in:
parent
6f870cc4f8
commit
9838b01467
3 changed files with 59 additions and 16 deletions
|
@ -5,6 +5,7 @@
|
||||||
provider-name="Emby.media">
|
provider-name="Emby.media">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.1.0"/>
|
<import addon="xbmc.python" version="2.1.0"/>
|
||||||
|
<import addon="script.module.myconnpy" version="0.3.2"/>
|
||||||
</requires>
|
</requires>
|
||||||
<extension point="xbmc.python.pluginsource"
|
<extension point="xbmc.python.pluginsource"
|
||||||
library="default.py">
|
library="default.py">
|
||||||
|
|
|
@ -11,7 +11,6 @@ import os
|
||||||
import cProfile
|
import cProfile
|
||||||
import pstats
|
import pstats
|
||||||
import time
|
import time
|
||||||
import sqlite3
|
|
||||||
import inspect
|
import inspect
|
||||||
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
@ -24,7 +23,7 @@ from DownloadUtils import DownloadUtils
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
addonSettings = xbmcaddon.Addon(id='plugin.video.emby')
|
addonSettings = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
language = addonSettings.getLocalizedString
|
language = addonSettings.getLocalizedString
|
||||||
DATABASE_VERSION_HELIX = "90"
|
|
||||||
|
|
||||||
def logMsg(title, msg, level = 1):
|
def logMsg(title, msg, level = 1):
|
||||||
logLevel = int(addonSettings.getSetting("logLevel"))
|
logLevel = int(addonSettings.getSetting("logLevel"))
|
||||||
|
@ -83,18 +82,68 @@ def checkKodiSources():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def KodiSQL():
|
||||||
|
if xbmc.getinfolabel("System.BuildVersion").startswith("13"):
|
||||||
|
#gotham
|
||||||
|
dbVersion = "78"
|
||||||
|
if xbmc.getinfolabel("System.BuildVersion").startswith("15"):
|
||||||
|
#isengard
|
||||||
|
dbVersion = "91"
|
||||||
|
else:
|
||||||
|
#helix
|
||||||
|
dbVersion = "90"
|
||||||
|
|
||||||
|
#find out if we should use MySQL
|
||||||
|
settingsFile = xbmc.translatePath( "special://profile/advancedsettings.xml" )
|
||||||
|
if xbmcvfs.exists(settingsFile):
|
||||||
|
tree = ET.ElementTree(file=settingsFile)
|
||||||
|
root = tree.getroot()
|
||||||
|
video = root.find("videolibrary")
|
||||||
|
if video != None:
|
||||||
|
mysql = video.find("type")
|
||||||
|
if mysql != None:
|
||||||
|
useMySQL = True
|
||||||
|
db_port = video.find("port").text
|
||||||
|
db_host = video.find("host").text
|
||||||
|
db_user = video.find("user").text
|
||||||
|
db_pass = video.find("pass").text
|
||||||
|
if video.find("name") != None:
|
||||||
|
db_name = video.find("name").text
|
||||||
|
else:
|
||||||
|
db_name = "MyVideos"
|
||||||
|
|
||||||
|
SubElement(video, "importwatchedstate").text = "true"
|
||||||
|
if video.find("importresumepoint") == None:
|
||||||
|
writeNeeded = True
|
||||||
|
SubElement(video, "importresumepoint").text = "true"
|
||||||
|
|
||||||
|
|
||||||
|
if useMySQL:
|
||||||
|
import local.mysql.connector as database
|
||||||
|
connection = database.connect(dbPath)
|
||||||
|
connection = database.connect(db = db_name, user = db_user, passwd = db_pass, host = db_host, port = db_port)
|
||||||
|
connection.set_charset('utf8')
|
||||||
|
connection.set_unicode(True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
import sqlite3 as database
|
||||||
|
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos" + dbVersion + ".db")
|
||||||
|
connection = database.connect(dbPath)
|
||||||
|
|
||||||
|
return connection
|
||||||
|
|
||||||
|
|
||||||
def addKodiSource(name, path, type):
|
def addKodiSource(name, path, type):
|
||||||
#add new source to database, common way is to add it directly to the Kodi DB. Fallback to adding it to the sources.xml
|
#add new source to database, common way is to add it directly to the Kodi DB. Fallback to adding it to the sources.xml
|
||||||
#return boolean wether a manual reboot is required.
|
#return boolean wether a manual reboot is required.
|
||||||
#todo: Do feature request with Kodi team to get support for adding a source by the json API
|
#todo: Do feature request with Kodi team to get support for adding a source by the json API
|
||||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos%s.db" % DATABASE_VERSION_HELIX)
|
|
||||||
|
|
||||||
error = False
|
error = False
|
||||||
if xbmcvfs.exists(dbPath):
|
if xbmcvfs.exists(dbPath):
|
||||||
try:
|
try:
|
||||||
connection = sqlite3.connect(dbPath)
|
connection = KodiSQL()
|
||||||
cursor = connection.cursor( )
|
cursor = connection.cursor( )
|
||||||
cursor.execute("select coalesce(max(idPath),0) as pathId from path")
|
cursor.execute("select coalesce(max(idPath),0) as pathId from path")
|
||||||
pathId = cursor.fetchone()[0]
|
pathId = cursor.fetchone()[0]
|
||||||
|
|
|
@ -818,9 +818,8 @@ class WriteKodiDB():
|
||||||
#season poster and banner are set by the nfo. landscape image is filled by this method
|
#season poster and banner are set by the nfo. landscape image is filled by this method
|
||||||
#if wanted this feature can be extended to also update the other artwork
|
#if wanted this feature can be extended to also update the other artwork
|
||||||
tvshowid = KodiItem["tvshowid"]
|
tvshowid = KodiItem["tvshowid"]
|
||||||
|
|
||||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos%s.db" % utils.DATABASE_VERSION_HELIX)
|
connection = utils.KodiSQL()
|
||||||
connection = sqlite3.connect(dbPath)
|
|
||||||
cursor = connection.cursor( )
|
cursor = connection.cursor( )
|
||||||
|
|
||||||
seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"])
|
seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"])
|
||||||
|
@ -848,8 +847,7 @@ class WriteKodiDB():
|
||||||
|
|
||||||
utils.logMsg("MB3 Sync","setting resume point in kodi db..." + fileType + ": " + str(id))
|
utils.logMsg("MB3 Sync","setting resume point in kodi db..." + fileType + ": " + str(id))
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos%s.db" % utils.DATABASE_VERSION_HELIX)
|
connection = utils.KodiSQL()
|
||||||
connection = sqlite3.connect(dbPath)
|
|
||||||
cursor = connection.cursor( )
|
cursor = connection.cursor( )
|
||||||
|
|
||||||
if fileType == "episode":
|
if fileType == "episode":
|
||||||
|
@ -901,10 +899,7 @@ class WriteKodiDB():
|
||||||
utils.logMsg("AddActorsToMedia", "List needs updating")
|
utils.logMsg("AddActorsToMedia", "List needs updating")
|
||||||
|
|
||||||
xbmc.sleep(sleepVal)
|
xbmc.sleep(sleepVal)
|
||||||
|
connection = utils.KodiSQL()
|
||||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos%s.db" % utils.DATABASE_VERSION_HELIX)
|
|
||||||
|
|
||||||
connection = sqlite3.connect(dbPath)
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
if(people != None):
|
if(people != None):
|
||||||
|
@ -942,9 +937,7 @@ class WriteKodiDB():
|
||||||
|
|
||||||
def addBoxsetToKodiLibrary(self, boxset):
|
def addBoxsetToKodiLibrary(self, boxset):
|
||||||
#use sqlite to set add the set
|
#use sqlite to set add the set
|
||||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos%s.db" % utils.DATABASE_VERSION_HELIX)
|
connection = utils.KodiSQL()
|
||||||
|
|
||||||
connection = sqlite3.connect(dbPath)
|
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
strSet = boxset["Name"]
|
strSet = boxset["Name"]
|
||||||
|
|
Loading…
Reference in a new issue