mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
first work on the video nodes stuff
This commit is contained in:
parent
f80e099b0c
commit
dd54cb27f3
3 changed files with 141 additions and 11 deletions
|
@ -28,11 +28,6 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
def onNotification (self,sender,method,data):
|
def onNotification (self,sender,method,data):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
print "onNotification:" + method + ":" + sender + ":" + str(data)
|
|
||||||
#player started playing an item -
|
|
||||||
if method == "Playlist.OnAdd":
|
|
||||||
print "playlist onadd is called"
|
|
||||||
|
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
jsondata = json.loads(data)
|
jsondata = json.loads(data)
|
||||||
|
|
|
@ -11,10 +11,6 @@ import os
|
||||||
|
|
||||||
import Utils as utils
|
import Utils as utils
|
||||||
|
|
||||||
|
|
||||||
#sleepval is used to throttle the calls to the xbmc json API
|
|
||||||
sleepVal = 15
|
|
||||||
|
|
||||||
class ReadKodiDB():
|
class ReadKodiDB():
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@ from ReadEmbyDB import ReadEmbyDB
|
||||||
from API import API
|
from API import API
|
||||||
import Utils as utils
|
import Utils as utils
|
||||||
|
|
||||||
sleepVal = 20
|
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
|
||||||
|
from xml.etree import ElementTree
|
||||||
|
from xml.dom import minidom
|
||||||
|
import xml.etree.cElementTree as ET
|
||||||
|
|
||||||
class WriteKodiDB():
|
class WriteKodiDB():
|
||||||
|
|
||||||
|
@ -909,6 +912,7 @@ class WriteKodiDB():
|
||||||
sql="insert into tag(tag_id, name) values(?, ?)"
|
sql="insert into tag(tag_id, name) values(?, ?)"
|
||||||
cursor.execute(sql, (tag_id,tag))
|
cursor.execute(sql, (tag_id,tag))
|
||||||
utils.logMsg("AddTagToMedia", "Adding tag: " + tag)
|
utils.logMsg("AddTagToMedia", "Adding tag: " + tag)
|
||||||
|
self.addVideoNodesForTag(tag, mediatype)
|
||||||
|
|
||||||
#assign tag to item
|
#assign tag to item
|
||||||
if doRemove:
|
if doRemove:
|
||||||
|
@ -931,6 +935,8 @@ class WriteKodiDB():
|
||||||
idTag = idTag + 1
|
idTag = idTag + 1
|
||||||
sql="insert into tag(idTag, strTag) values(?, ?)"
|
sql="insert into tag(idTag, strTag) values(?, ?)"
|
||||||
cursor.execute(sql, (idTag,tag))
|
cursor.execute(sql, (idTag,tag))
|
||||||
|
utils.logMsg("AddTagToMedia", "Adding tag: " + tag)
|
||||||
|
self.addVideoNodesForTag(tag, mediatype)
|
||||||
|
|
||||||
#assign tag to item
|
#assign tag to item
|
||||||
if doRemove:
|
if doRemove:
|
||||||
|
@ -1026,6 +1032,139 @@ class WriteKodiDB():
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def addVideoNodesForTag(self, tagname, type):
|
||||||
|
|
||||||
|
utils.logMsg("addVideoNodesForTag", "Creating nodes for tag: " + tagname)
|
||||||
|
libraryPath = xbmc.translatePath("special://userdata/library/video/emby/")
|
||||||
|
|
||||||
|
if type == "movie":
|
||||||
|
type = "movies"
|
||||||
|
elif type == "tvshow":
|
||||||
|
type = "tvshows"
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not xbmcvfs.exists(libraryPath):
|
||||||
|
#create root node
|
||||||
|
xbmcvfs.mkdir(libraryPath)
|
||||||
|
nodefile = os.path.join(libraryPath, "index.xml")
|
||||||
|
root = Element("node", {"order":"1"})
|
||||||
|
SubElement(root, "label").text = "Emby"
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#tagpath
|
||||||
|
libraryPath = xbmc.translatePath("special://userdata/library/video/emby/%s/" %tagname)
|
||||||
|
|
||||||
|
if not xbmcvfs.exists(libraryPath):
|
||||||
|
#create tag node - index
|
||||||
|
xbmcvfs.mkdir(libraryPath)
|
||||||
|
nodefile = os.path.join(libraryPath, "index.xml")
|
||||||
|
root = Element("node", {"order":"1"})
|
||||||
|
SubElement(root, "label").text = tagname
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#create tag node - all items
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_all.xml")
|
||||||
|
root = Element("node", {"order":"1", "type":"filter"})
|
||||||
|
SubElement(root, "label").text = tagname
|
||||||
|
SubElement(root, "match").text = "all"
|
||||||
|
SubElement(root, "content").text = type
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
Rule = SubElement(root, "rule", {"field":"tag","operator":"is"})
|
||||||
|
SubElement(Rule, "value").text = tagname
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#create tag node - recent items
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_recent.xml")
|
||||||
|
root = Element("node", {"order":"2", "type":"filter"})
|
||||||
|
SubElement(root, "label").text = tagname + " - Recently added"
|
||||||
|
SubElement(root, "match").text = "all"
|
||||||
|
SubElement(root, "content").text = type
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
Rule = SubElement(root, "rule", {"field":"tag","operator":"is"})
|
||||||
|
SubElement(Rule, "value").text = tagname
|
||||||
|
SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
|
||||||
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
SubElement(root, "limit").text = "25"
|
||||||
|
#exclude watched items --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
Rule2 = SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
||||||
|
SubElement(Rule2, "value").text = "0"
|
||||||
|
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#create tag node - inprogress items
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_progress.xml")
|
||||||
|
root = Element("node", {"order":"3", "type":"filter"})
|
||||||
|
SubElement(root, "label").text = tagname + " - In progress"
|
||||||
|
SubElement(root, "match").text = "all"
|
||||||
|
SubElement(root, "content").text = type
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
Rule = SubElement(root, "rule", {"field":"tag","operator":"is"})
|
||||||
|
SubElement(Rule, "value").text = tagname
|
||||||
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
SubElement(root, "limit").text = "25"
|
||||||
|
Rule2 = SubElement(root, "rule", {"field":"inprogress","operator":"true"})
|
||||||
|
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#add some additional nodes for episodes
|
||||||
|
if type == "tvshows":
|
||||||
|
#create tag node - recent episodes
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_recent_episodes.xml")
|
||||||
|
root = Element("node", {"order":"3", "type":"filter"})
|
||||||
|
SubElement(root, "label").text = tagname + " - Recently added episodes"
|
||||||
|
SubElement(root, "match").text = "all"
|
||||||
|
SubElement(root, "content").text = "episodes"
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
Rule = SubElement(root, "rule", {"field":"tag","operator":"is"})
|
||||||
|
SubElement(Rule, "value").text = tagname
|
||||||
|
SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
|
||||||
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
SubElement(root, "limit").text = "25"
|
||||||
|
#exclude watched items --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
Rule2 = SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
||||||
|
SubElement(Rule2, "value").text = "0"
|
||||||
|
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#create tag node - inprogress items
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_progress_episodes.xml")
|
||||||
|
root = Element("node", {"order":"4", "type":"filter"})
|
||||||
|
SubElement(root, "label").text = tagname + " - In progress episodes"
|
||||||
|
SubElement(root, "match").text = "all"
|
||||||
|
SubElement(root, "content").text = "episodes"
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
Rule = SubElement(root, "rule", {"field":"tag","operator":"is"})
|
||||||
|
SubElement(Rule, "value").text = tagname
|
||||||
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
||||||
|
SubElement(root, "limit").text = "25"
|
||||||
|
Rule2 = SubElement(root, "rule", {"field":"inprogress","operator":"true"})
|
||||||
|
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
def updateBoxsetToKodiLibrary(self, boxsetmovie, boxset, connection, cursor):
|
def updateBoxsetToKodiLibrary(self, boxsetmovie, boxset, connection, cursor):
|
||||||
strSet = boxset["Name"]
|
strSet = boxset["Name"]
|
||||||
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(boxsetmovie["Id"],))
|
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(boxsetmovie["Id"],))
|
||||||
|
|
Loading…
Reference in a new issue