mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-07-22 06:18:57 +00:00
fixed all properties for movieobjects
added actors to database fixed the library detection to more failsafe
This commit is contained in:
parent
7b45de29e1
commit
e2d6bd6c43
3 changed files with 141 additions and 85 deletions
|
@ -42,39 +42,22 @@ def logMsg(title, msg, level = 1):
|
|||
|
||||
|
||||
def checkKodiSources():
|
||||
print "All sources in Kodi -->"
|
||||
addon = xbmcaddon.Addon(id='plugin.video.mb3sync')
|
||||
addondir = xbmc.translatePath( addon.getAddonInfo('profile') )
|
||||
dataPath = os.path.join(addondir,"library\\")
|
||||
movieLibrary = os.path.join(dataPath,'movies\\')
|
||||
tvLibrary = os.path.join(dataPath,'tvshows\\')
|
||||
|
||||
dataPath = os.path.join(addondir,"library")
|
||||
movieLibrary = os.path.join(dataPath,'movies')
|
||||
tvLibrary = os.path.join(dataPath,'tvshows')
|
||||
|
||||
rebootRequired = False
|
||||
if not xbmcvfs.exists(dataPath):
|
||||
xbmcvfs.mkdir(dataPath)
|
||||
if not xbmcvfs.exists(movieLibrary):
|
||||
xbmcvfs.mkdir(movieLibrary)
|
||||
xbmcvfs.mkdir(movieLibrary)
|
||||
rebootRequired = addKodiSource("mediabrowser_movies",movieLibrary,"movies")
|
||||
if not xbmcvfs.exists(tvLibrary):
|
||||
xbmcvfs.mkdir(tvLibrary)
|
||||
|
||||
allKodiSources = list()
|
||||
|
||||
json_response = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetSources", "params": { "media": "video"}, "id": 1 }')
|
||||
jsonobject = json.loads(json_response.decode('utf-8','replace'))
|
||||
|
||||
if(jsonobject.has_key('result')):
|
||||
result = jsonobject['result']
|
||||
if(result.has_key('sources')):
|
||||
for source in result["sources"]:
|
||||
allKodiSources.append(source["label"])
|
||||
|
||||
allKodiSources = set(allKodiSources)
|
||||
|
||||
rebootRequired = False
|
||||
if not "mediabrowser_movies" in allKodiSources:
|
||||
rebootRequired = addKodiSource("mediabrowser_movies",movieLibrary,"movies")
|
||||
if not "mediabrowser_tvshows" in allKodiSources:
|
||||
rebootRequired = addKodiSource("mediabrowser_tvshows",tvLibrary,"tvshows")
|
||||
xbmcvfs.mkdir(tvLibrary)
|
||||
rebootRequired = addKodiSource("mediabrowser_tvshows",tvLibrary,"tvshows")
|
||||
|
||||
if rebootRequired:
|
||||
ret = xbmcgui.Dialog().yesno(heading="MediaBrowser Sync service", line1="A restart of Kodi is needed to apply changes. After the reboot you need to manually assign the MediaBrowser sources to your library. See documentation. Do you want to reboot now ?")
|
||||
if ret:
|
||||
|
@ -85,19 +68,25 @@ def addKodiSource(name, path, type):
|
|||
#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
|
||||
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos90.db")
|
||||
|
||||
error = False
|
||||
if xbmcvfs.exists(dbPath):
|
||||
connection = sqlite3.connect(dbPath)
|
||||
cursor = connection.cursor( )
|
||||
cursor.execute("select coalesce(max(idPath),0) as pathId from path")
|
||||
pathId = cursor.fetchone()[0]
|
||||
pathId = pathId + 1
|
||||
pathsql="insert into path(idPath, strPath, strContent, strScraper, strHash, scanRecursive) values(?, ?, ?, ?, ?, ?)"
|
||||
cursor.execute(pathsql, (pathId,path + "\\",type,"metadata.local",None,2147483647))
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
|
||||
return False
|
||||
try:
|
||||
connection = sqlite3.connect(dbPath)
|
||||
cursor = connection.cursor( )
|
||||
cursor.execute("select coalesce(max(idPath),0) as pathId from path")
|
||||
pathId = cursor.fetchone()[0]
|
||||
pathId = pathId + 1
|
||||
pathsql="insert into path(idPath, strPath, strContent, strScraper, strHash, scanRecursive) values(?, ?, ?, ?, ?, ?)"
|
||||
cursor.execute(pathsql, (pathId,path + "\\",type,"metadata.local",None,2147483647))
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
except:
|
||||
error = True
|
||||
else:
|
||||
error = True
|
||||
|
||||
if error:
|
||||
# if adding to the database failed, manually add it to sources.xml
|
||||
sourcesFile = xbmc.translatePath( "special://profile/sources.xml" )
|
||||
if xbmcvfs.exists(sourcesFile):
|
||||
|
@ -115,7 +104,11 @@ def addKodiSource(name, path, type):
|
|||
SubElement(source, "name").text = name
|
||||
SubElement(source, "path").text = path
|
||||
tree.write(sourcesFile)
|
||||
#return bool that reboot is needed and manual add of path to kodi
|
||||
return True
|
||||
else:
|
||||
#return false that no reboot is needed
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue