From c3eb8a5598cbe9b8208e56cd2417c44eb88c3e6a Mon Sep 17 00:00:00 2001
From: marcelveldt <m.vanderveldt@outlook.com>
Date: Fri, 23 Sep 2016 20:46:04 +0200
Subject: [PATCH] add favourite episodes node

---
 resources/lib/entrypoint.py  | 3 +++
 resources/lib/librarysync.py | 2 ++
 resources/lib/videonodes.py  | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py
index 1fa49c15..a5039945 100644
--- a/resources/lib/entrypoint.py
+++ b/resources/lib/entrypoint.py
@@ -605,6 +605,9 @@ def BrowseContent(viewname, browse_type="", folderid=""):
             listing = emby.getFilteredSection(folderid, itemtype=itemtype.split(",")[0], sortby="Random", recursive=True, limit=150, sortorder="Descending")
         elif filter_type == "recommended":
             listing = emby.getFilteredSection(folderid, itemtype=itemtype.split(",")[0], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter_type="IsFavorite")
+        elif folderid == "favepisodes":
+            xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
+            listing = emby.getFilteredSection(None, itemtype="Episode", sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter_type="IsFavorite")
         elif filter_type == "sets":
             listing = emby.getFilteredSection(folderid, itemtype=itemtype.split(",")[1], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter_type="IsFavorite")
         else:
diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py
index df3ccb12..77264f94 100644
--- a/resources/lib/librarysync.py
+++ b/resources/lib/librarysync.py
@@ -582,6 +582,8 @@ class LibrarySync(threading.Thread):
             totalnodes += 1
             self.vnodes.singleNode(totalnodes, "Favorite tvshows", "tvshows", "favourites")
             totalnodes += 1
+            self.vnodes.singleNode(totalnodes, "Favorite episodes", "episodes", "favourites")
+            totalnodes += 1
             self.vnodes.singleNode(totalnodes, "channels", "movies", "channels")
             totalnodes += 1
             # Save total
diff --git a/resources/lib/videonodes.py b/resources/lib/videonodes.py
index d2157e27..f8475d79 100644
--- a/resources/lib/videonodes.py
+++ b/resources/lib/videonodes.py
@@ -333,6 +333,7 @@ class VideoNodes(object):
 
             'Favorite movies': 30180,
             'Favorite tvshows': 30181,
+            'Favorite episodes': 30182,
             'channels': 30173
         }
         label = lang(labels[tagname])
@@ -349,6 +350,9 @@ class VideoNodes(object):
         if itemtype == "channels":
             root = self.commonRoot(order=1, label=label, tagname=tagname, roottype=2)
             etree.SubElement(root, 'path').text = "plugin://plugin.video.emby/?id=0&mode=channels"
+        elif itemtype == "favourites" and mediatype == "episodes":
+            root = self.commonRoot(order=1, label=label, tagname=tagname, roottype=2)
+            etree.SubElement(root, 'path').text = "plugin://plugin.video.emby/?id=%s&mode=browsecontent&type=%s&folderid=favepisodes" %(tagname, mediatype)
         else:
             root = self.commonRoot(order=1, label=label, tagname=tagname)
             etree.SubElement(root, 'order', {'direction': "ascending"}).text = "sorttitle"