mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
auto add new library sources to kodi database
This commit is contained in:
parent
860bdfbbd8
commit
85550ce1ad
2 changed files with 28 additions and 14 deletions
|
@ -12,6 +12,7 @@ import urllib
|
||||||
from datetime import datetime, timedelta, time
|
from datetime import datetime, timedelta, time
|
||||||
import urllib2
|
import urllib2
|
||||||
import os
|
import os
|
||||||
|
|
||||||
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
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
@ -198,11 +199,11 @@ class LibrarySync():
|
||||||
|
|
||||||
root = Element("movie")
|
root = Element("movie")
|
||||||
SubElement(root, "id").text = item["Id"]
|
SubElement(root, "id").text = item["Id"]
|
||||||
SubElement(root, "tag").text = item["Id"]
|
SubElement(root, "tag").text = "all mediabrowser movies" # TODO --> use tags to assign user view
|
||||||
SubElement(root, "thumb").text = downloadUtils.getArtwork(item, "poster")
|
SubElement(root, "thumb").text = downloadUtils.getArtwork(item, "poster")
|
||||||
SubElement(root, "fanart").text = timeInfo.get('Backdrop')
|
SubElement(root, "fanart").text = downloadUtils.getArtwork(item, "Backdrop")
|
||||||
SubElement(root, "title").text = item["Name"].encode('utf-8').decode('utf-8')
|
SubElement(root, "title").text = item["Name"].encode('utf-8').decode('utf-8')
|
||||||
SubElement(root, "originaltitle").text = item["Id"]
|
SubElement(root, "originaltitle").text = item["Name"].encode('utf-8').decode('utf-8')
|
||||||
|
|
||||||
SubElement(root, "year").text = str(item.get("ProductionYear"))
|
SubElement(root, "year").text = str(item.get("ProductionYear"))
|
||||||
SubElement(root, "runtime").text = str(timeInfo.get('Duration'))
|
SubElement(root, "runtime").text = str(timeInfo.get('Duration'))
|
||||||
|
@ -210,14 +211,14 @@ class LibrarySync():
|
||||||
fileinfo = SubElement(root, "fileinfo")
|
fileinfo = SubElement(root, "fileinfo")
|
||||||
streamdetails = SubElement(fileinfo, "streamdetails")
|
streamdetails = SubElement(fileinfo, "streamdetails")
|
||||||
video = SubElement(streamdetails, "video")
|
video = SubElement(streamdetails, "video")
|
||||||
SubElement(video, "duration").text = str(timeInfo.get('totaltime'))
|
SubElement(video, "duration").text = str(mediaStreams.get('totaltime'))
|
||||||
SubElement(video, "aspect").text = timeInfo.get('aspectratio')
|
SubElement(video, "aspect").text = mediaStreams.get('aspectratio')
|
||||||
SubElement(video, "codec").text = timeInfo.get('videocodec')
|
SubElement(video, "codec").text = mediaStreams.get('videocodec')
|
||||||
SubElement(video, "width").text = str(timeInfo.get('width'))
|
SubElement(video, "width").text = str(mediaStreams.get('width'))
|
||||||
SubElement(video, "height").text = str(timeInfo.get('height'))
|
SubElement(video, "height").text = str(mediaStreams.get('height'))
|
||||||
audio = SubElement(streamdetails, "audio")
|
audio = SubElement(streamdetails, "audio")
|
||||||
SubElement(audio, "codec").text = timeInfo.get('audiocodec')
|
SubElement(audio, "codec").text = mediaStreams.get('audiocodec')
|
||||||
SubElement(audio, "channels").text = timeInfo.get('channels')
|
SubElement(audio, "channels").text = mediaStreams.get('channels')
|
||||||
|
|
||||||
SubElement(root, "plot").text = API().getOverview(item).decode('utf-8')
|
SubElement(root, "plot").text = API().getOverview(item).decode('utf-8')
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ import xbmcaddon
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -70,10 +72,10 @@ def checkKodiSources():
|
||||||
|
|
||||||
rebootRequired = False
|
rebootRequired = False
|
||||||
if not "mediabrowser_movies" in allKodiSources:
|
if not "mediabrowser_movies" in allKodiSources:
|
||||||
addKodiSource("mediabrowser_movies",movieLibrary)
|
addKodiSource("mediabrowser_movies",movieLibrary,"movies")
|
||||||
rebootRequired = True
|
rebootRequired = True
|
||||||
if not "mediabrowser_tvshows" in allKodiSources:
|
if not "mediabrowser_tvshows" in allKodiSources:
|
||||||
addKodiSource("mediabrowser_tvshows",tvLibrary)
|
addKodiSource("mediabrowser_tvshows",tvLibrary,"tvshows")
|
||||||
rebootRequired = True
|
rebootRequired = True
|
||||||
|
|
||||||
if rebootRequired:
|
if rebootRequired:
|
||||||
|
@ -81,7 +83,7 @@ def checkKodiSources():
|
||||||
if ret:
|
if ret:
|
||||||
xbmc.executebuiltin("RestartApp")
|
xbmc.executebuiltin("RestartApp")
|
||||||
|
|
||||||
def addKodiSource(name, path):
|
def addKodiSource(name, path, type):
|
||||||
userDataPath = xbmc.translatePath( "special://profile" )
|
userDataPath = xbmc.translatePath( "special://profile" )
|
||||||
sourcesFile = os.path.join(userDataPath,'sources.xml')
|
sourcesFile = os.path.join(userDataPath,'sources.xml')
|
||||||
|
|
||||||
|
@ -103,9 +105,20 @@ def addKodiSource(name, path):
|
||||||
source = SubElement(videosources,'source')
|
source = SubElement(videosources,'source')
|
||||||
SubElement(source, "name").text = name
|
SubElement(source, "name").text = name
|
||||||
SubElement(source, "path").text = path
|
SubElement(source, "path").text = path
|
||||||
|
|
||||||
tree.write(sourcesFile)
|
tree.write(sourcesFile)
|
||||||
|
|
||||||
|
#add new source to database
|
||||||
|
dbPath = xbmc.translatePath("special://userdata/Database/MyVideos90.db")
|
||||||
|
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()
|
||||||
|
|
||||||
def checkAuthentication():
|
def checkAuthentication():
|
||||||
#check authentication
|
#check authentication
|
||||||
if addonSettings.getSetting('username') != "" and addonSettings.getSetting('ipaddress') != "":
|
if addonSettings.getSetting('username') != "" and addonSettings.getSetting('ipaddress') != "":
|
||||||
|
|
Loading…
Reference in a new issue