2015-05-07 07:24:13 +10:00
|
|
|
#################################################################################################
|
|
|
|
# VideoNodes - utils to create video nodes listings in kodi for the emby addon
|
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
import xbmc
|
|
|
|
import xbmcgui
|
|
|
|
import xbmcaddon
|
|
|
|
import xbmcvfs
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import shutil
|
2015-05-07 18:33:35 +10:00
|
|
|
#import common elementree because cElementree has issues with kodi
|
2015-05-07 18:32:30 +10:00
|
|
|
import xml.etree.ElementTree as etree
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
import Utils as utils
|
|
|
|
|
|
|
|
from ReadEmbyDB import ReadEmbyDB
|
|
|
|
WINDOW = xbmcgui.Window(10000)
|
|
|
|
|
|
|
|
addonSettings = xbmcaddon.Addon(id='plugin.video.emby')
|
|
|
|
language = addonSettings.getLocalizedString
|
|
|
|
|
|
|
|
class VideoNodes():
|
|
|
|
|
|
|
|
|
|
|
|
def buildVideoNodeForView(self, tagname, type, windowPropId):
|
|
|
|
#this method will build a video node for a particular Emby view (= tag in kodi)
|
|
|
|
#we set some window props here to for easy future reference and to be used in skins (for easy access only)
|
2015-08-03 19:45:23 +10:00
|
|
|
tagname_normalized = utils.normalize_nodes(tagname.encode('utf-8'))
|
2015-05-07 07:24:13 +10:00
|
|
|
|
2015-08-03 09:52:47 +10:00
|
|
|
libraryPath = xbmc.translatePath("special://profile/library/video/Emby - %s/" %tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
kodiVersion = 14
|
2015-07-28 03:41:01 +10:00
|
|
|
if xbmc.getInfoLabel("System.BuildVersion").startswith("15") or xbmc.getInfoLabel("System.BuildVersion").startswith("16"):
|
2015-05-09 20:53:23 +10:00
|
|
|
kodiVersion = 15
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - index
|
|
|
|
xbmcvfs.mkdir(libraryPath)
|
|
|
|
nodefile = os.path.join(libraryPath, "index.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"0"})
|
2015-05-08 09:45:28 +10:00
|
|
|
etree.SubElement(root, "label").text = tagname
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/" %tagname_normalized
|
2015-05-07 08:05:27 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.index" %str(windowPropId),path)
|
2015-05-07 18:33:35 +10:00
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - all items
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_all.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"1", "type":"filter"})
|
|
|
|
etree.SubElement(root, "label").text = tagname
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = type
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.title" %str(windowPropId),tagname)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_all.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.content" %str(windowPropId),path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.type" %str(windowPropId),type)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
2015-05-07 07:24:13 +10:00
|
|
|
try:
|
2015-05-09 20:53:23 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-09 20:53:23 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - recent items
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_recent.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"2", "type":"filter"})
|
2015-05-07 07:24:13 +10:00
|
|
|
if type == "tvshows":
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30170)
|
2015-05-07 07:24:13 +10:00
|
|
|
else:
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30174)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = type
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
etree.SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
|
2015-05-07 07:24:13 +10:00
|
|
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "limit").text = "25"
|
2015-05-07 07:24:13 +10:00
|
|
|
#exclude watched items --> currently hardcoded --> TODO: add a setting for this ?
|
2015-05-07 18:32:30 +10:00
|
|
|
Rule2 = etree.SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
|
|
|
etree.SubElement(Rule2, "value").text = "0"
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recent.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_recent.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recent.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recent.content" %str(windowPropId),path)
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - inprogress items
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_progress.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"3", "type":"filter"})
|
2015-05-07 07:24:13 +10:00
|
|
|
if type == "tvshows":
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30171)
|
2015-05-07 07:24:13 +10:00
|
|
|
else:
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30177)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = type
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
2015-05-07 07:24:13 +10:00
|
|
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "limit").text = "25"
|
|
|
|
Rule2 = etree.SubElement(root, "rule", {"field":"inprogress","operator":"true"})
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogress.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_progress.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogress.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogress.content" %str(windowPropId),path)
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
2015-05-09 20:53:23 +10:00
|
|
|
#some movies-only nodes
|
2015-05-07 07:24:13 +10:00
|
|
|
if type == "movies":
|
2015-05-09 20:53:23 +10:00
|
|
|
|
|
|
|
#unwatched movies
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_unwatched.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"4", "type":"filter"})
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30189)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = "movies"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = "0"
|
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule2 = etree.SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
|
|
|
etree.SubElement(Rule2, "value").text = "0"
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.unwatched.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_unwatched.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.unwatched.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.unwatched.content" %str(windowPropId),path)
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
2015-05-09 20:53:23 +10:00
|
|
|
#sets
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_sets.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"9", "type":"filter"})
|
|
|
|
label = xbmc.getLocalizedString(20434)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
2015-05-09 20:53:23 +10:00
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "group").text = "sets"
|
|
|
|
etree.SubElement(root, "content").text = type
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
2015-05-09 20:53:23 +10:00
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.sets.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_sets.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.sets.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.sets.content" %str(windowPropId),path)
|
2015-05-07 07:24:13 +10:00
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-09 20:53:23 +10:00
|
|
|
|
|
|
|
#create tag node - genres
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_genres.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"9", "type":"filter"})
|
|
|
|
label = xbmc.getLocalizedString(135)
|
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "group").text = "genres"
|
|
|
|
etree.SubElement(root, "content").text = type
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.genres.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_genres.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.genres.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.genres.content" %str(windowPropId),path)
|
|
|
|
|
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
|
|
|
|
|
|
|
|
|
|
|
#### TAGS ONLY FOR TV SHOWS COLLECTIONS ####
|
|
|
|
if type == "tvshows":
|
|
|
|
|
|
|
|
#as from kodi isengard you can use tags for episodes to filter
|
|
|
|
#for below isengard we still use the plugin's entrypoint to build a listing
|
|
|
|
if kodiVersion == 15:
|
|
|
|
#create tag node - recent episodes
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_recent_episodes.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"3", "type":"filter"})
|
|
|
|
label = language(30175)
|
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = "episodes"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
etree.SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
|
|
|
etree.SubElement(root, "limit").text = "25"
|
|
|
|
#exclude watched items --> currently hardcoded --> TODO: add a setting for this ?
|
|
|
|
Rule2 = etree.SubElement(root, "rule", {"field":"playcount","operator":"is"})
|
|
|
|
etree.SubElement(Rule2, "value").text = "0"
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_recent_episodes.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.content" %str(windowPropId),path)
|
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
2015-05-09 20:53:23 +10:00
|
|
|
#create tag node - inprogress episodes
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_progress_episodes.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"4", "type":"filter"})
|
|
|
|
label = language(30178)
|
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = "episodes"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = tagname
|
|
|
|
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
|
|
|
etree.SubElement(root, "limit").text = "25"
|
|
|
|
Rule2 = etree.SubElement(root, "rule", {"field":"inprogress","operator":"true"})
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_progress_episodes.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.content" %str(windowPropId),path)
|
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
|
|
|
|
|
|
|
if kodiVersion == 14:
|
|
|
|
#create tag node - recent episodes
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_recent_episodes.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"4", "type":"folder"})
|
|
|
|
label = language(30175)
|
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "content").text = "episodes"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
path = "plugin://plugin.video.emby/?id=%s&mode=recentepisodes&limit=25" %tagname
|
|
|
|
etree.SubElement(root, "path").text = path
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_recent_episodes.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.content" %str(windowPropId),path)
|
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
|
|
|
|
|
|
|
#create tag node - inprogress items
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_progress_episodes.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"5", "type":"folder"})
|
|
|
|
label = language(30178)
|
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "content").text = "episodes"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25" %tagname
|
|
|
|
etree.SubElement(root, "path").text = path
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_progress_episodes.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-09 20:53:23 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.content" %str(windowPropId),path)
|
|
|
|
try:
|
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
|
|
|
except:
|
|
|
|
etree.ElementTree(root).write(nodefile)
|
|
|
|
|
2015-05-07 07:24:13 +10:00
|
|
|
#create tag node - nextup items
|
2015-05-09 20:53:23 +10:00
|
|
|
#for nextup we always use the dynamic content approach with the plugin's entrypoint because it involves a custom query
|
2015-08-03 09:52:47 +10:00
|
|
|
nodefile = os.path.join(libraryPath, tagname_normalized + "_nextup_episodes.xml")
|
2015-05-09 20:53:23 +10:00
|
|
|
root = etree.Element("node", {"order":"6", "type":"folder"})
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30179)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "content").text = "episodes"
|
2015-05-09 03:10:58 +10:00
|
|
|
path = "plugin://plugin.video.emby/?id=%s&mode=nextup&limit=25" %tagname
|
|
|
|
etree.SubElement(root, "path").text = path
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.nextepisodes.title" %str(windowPropId),label)
|
2015-08-03 09:52:47 +10:00
|
|
|
path = "library://video/Emby - %s/%s_nextup_episodes.xml"%(tagname_normalized,tagname_normalized)
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.nextepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.nextepisodes.content" %str(windowPropId),path)
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
def buildVideoNodesListing(self):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# the library path doesn't exist on all systems
|
|
|
|
if not xbmcvfs.exists("special://profile/library/"):
|
|
|
|
xbmcvfs.mkdir("special://profile/library")
|
|
|
|
if not xbmcvfs.exists("special://profile/library/video/"):
|
|
|
|
#we need to copy over the default items
|
|
|
|
shutil.copytree(xbmc.translatePath("special://xbmc/system/library/video"), xbmc.translatePath("special://profile/library/video"))
|
|
|
|
|
|
|
|
#always cleanup existing Emby video nodes first because we don't want old stuff to stay in there
|
|
|
|
path = "special://profile/library/video/"
|
|
|
|
if xbmcvfs.exists(path):
|
|
|
|
allDirs, allFiles = xbmcvfs.listdir(path)
|
|
|
|
for dir in allDirs:
|
|
|
|
if dir.startswith("Emby "):
|
|
|
|
shutil.rmtree(xbmc.translatePath("special://profile/library/video/" + dir))
|
|
|
|
for file in allFiles:
|
|
|
|
if file.startswith("emby"):
|
|
|
|
xbmcvfs.delete(path + file)
|
|
|
|
|
|
|
|
#we build up a listing and set window props for all nodes we created
|
|
|
|
#the window props will be used by the main entry point to quickly build up the listing and can be used in skins (like titan) too for quick reference
|
|
|
|
#comment marcelveldt: please leave the window props as-is because I will be referencing them in titan skin...
|
|
|
|
totalNodesCount = 0
|
|
|
|
|
|
|
|
#build the listing for all views
|
|
|
|
views_movies = ReadEmbyDB().getCollections("movies")
|
|
|
|
if views_movies:
|
|
|
|
for view in views_movies:
|
|
|
|
self.buildVideoNodeForView(view.get('title'), "movies", totalNodesCount)
|
|
|
|
totalNodesCount +=1
|
|
|
|
|
|
|
|
views_shows = ReadEmbyDB().getCollections("tvshows")
|
|
|
|
if views_shows:
|
|
|
|
for view in views_shows:
|
|
|
|
self.buildVideoNodeForView(view.get('title'), "tvshows", totalNodesCount)
|
|
|
|
totalNodesCount +=1
|
|
|
|
|
|
|
|
#create tag node for emby channels
|
|
|
|
nodefile = os.path.join(xbmc.translatePath("special://profile/library/video"), "emby_channels.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"1", "type":"folder"})
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30173)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "content").text = "movies"
|
|
|
|
etree.SubElement(root, "path").text = "plugin://plugin.video.emby/?id=0&mode=channels"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.title" %str(totalNodesCount),label)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.type" %str(totalNodesCount),"channels")
|
|
|
|
path = "library://video/emby_channels.xml"
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.path" %str(totalNodesCount),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.content" %str(totalNodesCount),path)
|
|
|
|
totalNodesCount +=1
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - favorite shows
|
|
|
|
nodefile = os.path.join(xbmc.translatePath("special://profile/library/video"),"emby_favorite_shows.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"1", "type":"filter"})
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30181)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = "tvshows"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = "Favorite tvshows" #do not localize the tagname itself
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.title" %str(totalNodesCount),label)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.type" %str(totalNodesCount),"favourites")
|
|
|
|
path = "library://video/emby_favorite_shows.xml"
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.path" %str(totalNodesCount),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.content" %str(totalNodesCount),path)
|
|
|
|
totalNodesCount +=1
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
#create tag node - favorite movies
|
|
|
|
nodefile = os.path.join(xbmc.translatePath("special://profile/library/video"),"emby_favorite_movies.xml")
|
2015-05-07 18:32:30 +10:00
|
|
|
root = etree.Element("node", {"order":"1", "type":"filter"})
|
2015-05-08 09:45:28 +10:00
|
|
|
label = language(30180)
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.SubElement(root, "label").text = label
|
|
|
|
etree.SubElement(root, "match").text = "all"
|
|
|
|
etree.SubElement(root, "content").text = "movies"
|
|
|
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
|
|
|
etree.SubElement(root, "order", {"direction":"ascending"}).text = "sorttitle"
|
|
|
|
Rule = etree.SubElement(root, "rule", {"field":"tag","operator":"is"})
|
|
|
|
etree.SubElement(Rule, "value").text = "Favorite movies" #do not localize the tagname itself
|
2015-05-07 07:24:13 +10:00
|
|
|
WINDOW.setProperty("Emby.nodes.%s.title" %str(totalNodesCount),label)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.type" %str(totalNodesCount),"favourites")
|
|
|
|
path = "library://video/emby_favorite_movies.xml"
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.path" %str(totalNodesCount),"ActivateWindow(Video,%s,return)"%path)
|
|
|
|
WINDOW.setProperty("Emby.nodes.%s.content" %str(totalNodesCount),path)
|
|
|
|
totalNodesCount +=1
|
|
|
|
try:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile, xml_declaration=True)
|
2015-05-07 07:24:13 +10:00
|
|
|
except:
|
2015-05-07 18:32:30 +10:00
|
|
|
etree.ElementTree(root).write(nodefile)
|
2015-05-07 07:24:13 +10:00
|
|
|
|
|
|
|
WINDOW.setProperty("Emby.nodes.total", str(totalNodesCount))
|
|
|
|
|
2015-05-07 18:32:30 +10:00
|
|
|
|
2015-05-07 07:24:13 +10:00
|
|
|
except Exception as e:
|
|
|
|
utils.logMsg("Emby addon","Error while creating videonodes listings, restart required ?")
|
2015-05-07 18:32:30 +10:00
|
|
|
print e
|