From 3e1efdf82436b90b9d75687b8b58a44108931be7 Mon Sep 17 00:00:00 2001 From: marcelveldt Date: Mon, 23 Nov 2015 18:45:42 +0100 Subject: [PATCH] add recommended and random nodes --- resources/language/English/strings.xml | 2 ++ resources/lib/VideoNodes.py | 49 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index c5b355b2..fda8a302 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -221,6 +221,8 @@ Random Movies Random Episodes + Random Items + Recommended Items Extras Sync Theme Music diff --git a/resources/lib/VideoNodes.py b/resources/lib/VideoNodes.py index 0e1089d5..056ee13f 100644 --- a/resources/lib/VideoNodes.py +++ b/resources/lib/VideoNodes.py @@ -189,7 +189,54 @@ class VideoNodes(): etree.ElementTree(root).write(nodefile, xml_declaration=True) except: etree.ElementTree(root).write(nodefile) - + + #create tag node - random items + nodefile = os.path.join(libraryPath, tagname_normalized + "_random.xml") + root = etree.Element("node", {"order":"10", "type":"filter"}) + label = language(30229) + 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 + #set limit to 25 --> currently hardcoded --> TODO: add a setting for this ? + etree.SubElement(root, "limit").text = "25" + etree.SubElement(root, "order", {"direction":"ascending"}).text = "random" + WINDOW.setProperty("Emby.nodes.%s.random.title" %str(windowPropId),label) + path = "library://video/Emby - %s/%s_random.xml"%(tagname_normalized,tagname_normalized) + WINDOW.setProperty("Emby.nodes.%s.random.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path) + WINDOW.setProperty("Emby.nodes.%s.random.content" %str(windowPropId),path) + try: + etree.ElementTree(root).write(nodefile, xml_declaration=True) + except: + etree.ElementTree(root).write(nodefile) + + #create tag node - recommended items + nodefile = os.path.join(libraryPath, tagname_normalized + "_recommended.xml") + root = etree.Element("node", {"order":"10", "type":"filter"}) + label = language(30230) + 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 + Rule2 = etree.SubElement(root, "rule", {"field":"playcount","operator":"is"}) + etree.SubElement(Rule2, "value").text = "0" + Rule3 = etree.SubElement(root, "rule", {"field":"rating","operator":"greaterthan"}) + etree.SubElement(Rule3, "value").text = "7" + #set limit to 25 --> currently hardcoded --> TODO: add a setting for this ? + etree.SubElement(root, "limit").text = "25" + etree.SubElement(root, "order", {"direction":"descending"}).text = "rating" + WINDOW.setProperty("Emby.nodes.%s.random.title" %str(windowPropId),label) + path = "library://video/Emby - %s/%s_recommended.xml"%(tagname_normalized,tagname_normalized) + WINDOW.setProperty("Emby.nodes.%s.recommended.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path) + WINDOW.setProperty("Emby.nodes.%s.recommended.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":