(finally) fixed the video node sublevels filtered on tagname with episodes

This commit is contained in:
Marcel van der Veldt 2015-05-09 03:16:03 +02:00
parent aeff7778e1
commit 1e61c9edc8
3 changed files with 108 additions and 51 deletions

View file

@ -62,6 +62,15 @@ elif mode == "nextup":
limit = int(params['limit'])
entrypoint.getNextUpEpisodes(id, limit)
##### GET INPROGRESS EPISODES FOR TAGNAME #####
elif mode == "inprogressepisodes":
limit = int(params['limit'])
entrypoint.getInProgressEpisodes(id, limit)
##### GET RECENT EPISODES FOR TAGNAME #####
elif mode == "recentepisodes":
limit = int(params['limit'])
entrypoint.getRecentEpisodes(id, limit)
##### GET EXTRAFANART FOR LISTITEM #####
elif "extrafanart" in sys.argv[0]:

View file

@ -285,6 +285,67 @@ def getNextUpEpisodes(tagname,limit):
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
count = 0
for item in json_query2['result']['episodes']:
liz = createListItem(item)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
count +=1
if count == limit:
break
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
def getInProgressEpisodes(tagname,limit):
#if the addon is called with inprogressepisodes parameter, we return the inprogressepisodes list of the given tagname
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
# First we get a list of all the in-progress TV shows - filtered by tag
json_query_string = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "sort": { "order": "descending", "method": "lastplayed" }, "filter": {"and": [{"operator":"true", "field":"inprogress", "value":""}, {"operator": "contains", "field": "tag", "value": "%s"}]}, "properties": [ "title", "studio", "mpaa", "file", "art" ] }, "id": "libTvShows"}' %tagname)
json_result = json.loads(json_query_string)
# If we found any, find all in progress episodes for each one.
if json_result.has_key('result') and json_result['result'].has_key('tvshows'):
for item in json_result['result']['tvshows']:
json_query2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "tvshowid": %d, "sort": {"method":"episode"}, "filter": {"field": "inprogress", "operator": "true", "value":""}, "properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "writer", "dateadded", "lastplayed" ]}, "id": "1"}' %item['tvshowid'])
if json_query2:
json_query2 = json.loads(json_query2)
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
count = 0
for item in json_query2['result']['episodes']:
liz = createListItem(item)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
count +=1
if count == limit:
break
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
def getRecentEpisodes(tagname,limit):
#if the addon is called with recentepisodes parameter, we return the recentepisodes list of the given tagname
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
# First we get a list of all the TV shows - filtered by tag
json_query_string = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "sort": { "order": "descending", "method": "dateadded" }, "properties": [ "title","sorttitle" ], "filter": {"operator": "contains", "field": "tag", "value": "%s"} }, "id": "libTvShows"}' %tagname)
json_result = json.loads(json_query_string)
# If we found any, put all tv show id's in a list
if json_result.has_key('result') and json_result['result'].has_key('tvshows'):
alltvshowIds = list()
for tvshow in json_result['result']['tvshows']:
alltvshowIds.append(tvshow["tvshowid"])
alltvshowIds = set(alltvshowIds)
#get all recently added episodes
json_query2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "sort": {"order": "descending", "method": "dateadded"}, "filter": {"field": "playcount", "operator": "lessthan", "value":"1"}, "properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime", "writer", "dateadded", "lastplayed" ]}, "limits":{"end":%d}, "id": "1"}' %limit)
count = 0
if json_query2:
json_query2 = json.loads(json_query2)
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
for item in json_query2['result']['episodes']:
if item["tvshowid"] in alltvshowIds:
liz = createListItem(item)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
count += 1
if count >= limit:
break
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
def createListItem(item):
episode = "%.2d" % float(item['episode'])
season = "%.2d" % float(item['season'])
episodeno = "s%se%s" %(season,episode)
@ -321,12 +382,8 @@ def getNextUpEpisodes(tagname,limit):
for key, value in item['streamdetails'].iteritems():
for stream in value:
liz.addStreamInfo( key, stream )
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
count +=1
if count == limit:
break
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
return liz
##### GET EXTRAFANART FOR LISTITEM #####
def getExtraFanArt():

View file

@ -149,19 +149,13 @@ class VideoNodes():
if type == "tvshows":
#create tag node - recent episodes
nodefile = os.path.join(libraryPath, tagname + "_recent_episodes.xml")
root = etree.Element("node", {"order":"3", "type":"filter"})
root = etree.Element("node", {"order":"3", "type":"folder"})
label = language(30175)
etree.SubElement(root, "label").text = label
etree.SubElement(root, "match").text = "all"
etree.SubElement(root, "content").text = "episodes"
etree.SubElement(root, "path").text = nodefile_root
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
etree.SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
#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"
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)
path = "library://video/Emby - %s/%s_recent_episodes.xml"%(tagname,tagname)
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
@ -173,16 +167,13 @@ class VideoNodes():
#create tag node - inprogress items
nodefile = os.path.join(libraryPath, tagname + "_progress_episodes.xml")
root = etree.Element("node", {"order":"4", "type":"filter"})
root = etree.Element("node", {"order":"4", "type":"folder"})
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"
etree.SubElement(root, "path").text = nodefile_root
#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"})
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)
path = "library://video/Emby - %s/%s_progress_episodes.xml"%(tagname,tagname)
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)