mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
(finally) fixed the video node sublevels filtered on tagname with episodes
This commit is contained in:
parent
aeff7778e1
commit
1e61c9edc8
3 changed files with 108 additions and 51 deletions
|
@ -62,6 +62,15 @@ elif mode == "nextup":
|
||||||
limit = int(params['limit'])
|
limit = int(params['limit'])
|
||||||
entrypoint.getNextUpEpisodes(id, 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 #####
|
##### GET EXTRAFANART FOR LISTITEM #####
|
||||||
elif "extrafanart" in sys.argv[0]:
|
elif "extrafanart" in sys.argv[0]:
|
||||||
|
|
|
@ -285,48 +285,105 @@ def getNextUpEpisodes(tagname,limit):
|
||||||
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
|
if json_query2.has_key('result') and json_query2['result'].has_key('episodes'):
|
||||||
count = 0
|
count = 0
|
||||||
for item in json_query2['result']['episodes']:
|
for item in json_query2['result']['episodes']:
|
||||||
episode = "%.2d" % float(item['episode'])
|
liz = createListItem(item)
|
||||||
season = "%.2d" % float(item['season'])
|
|
||||||
episodeno = "s%se%s" %(season,episode)
|
|
||||||
watched = False
|
|
||||||
if item['playcount'] >= 1:
|
|
||||||
watched = True
|
|
||||||
plot = item['plot']
|
|
||||||
liz = xbmcgui.ListItem(item['title'])
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Title": item['title'] })
|
|
||||||
liz.setProperty('IsPlayable', 'true')
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "duration": str(item['runtime']/60) })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Episode": item['episode'] })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Season": item['season'] })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Premiered": item['firstaired'] })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Plot": plot })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "TVshowTitle": item['showtitle'] })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Rating": str(round(float(item['rating']),1)) })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Playcount": item['playcount'] })
|
|
||||||
if "director" in item:
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Director": " / ".join(item['director']) })
|
|
||||||
if "writer" in item:
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Writer": " / ".join(item['writer']) })
|
|
||||||
if "cast" in item:
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "Cast": cast[0] })
|
|
||||||
liz.setInfo( type="Video", infoLabels={ "CastAndRole": cast[1] })
|
|
||||||
liz.setProperty("episodeno", episodeno)
|
|
||||||
liz.setProperty("resumetime", str(item['resume']['position']))
|
|
||||||
liz.setProperty("totaltime", str(item['resume']['total']))
|
|
||||||
liz.setArt(item['art'])
|
|
||||||
liz.setThumbnailImage(item['art'].get('thumb',''))
|
|
||||||
liz.setIconImage('DefaultTVShows.png')
|
|
||||||
liz.setProperty("dbid", str(item['episodeid']))
|
|
||||||
liz.setProperty("fanart_image", item['art'].get('tvshow.fanart',''))
|
|
||||||
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)
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
|
||||||
count +=1
|
count +=1
|
||||||
if count == limit:
|
if count == limit:
|
||||||
break
|
break
|
||||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
|
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)
|
||||||
|
watched = False
|
||||||
|
if item['playcount'] >= 1:
|
||||||
|
watched = True
|
||||||
|
plot = item['plot']
|
||||||
|
liz = xbmcgui.ListItem(item['title'])
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Title": item['title'] })
|
||||||
|
liz.setProperty('IsPlayable', 'true')
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "duration": str(item['runtime']/60) })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Episode": item['episode'] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Season": item['season'] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Premiered": item['firstaired'] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Plot": plot })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "TVshowTitle": item['showtitle'] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Rating": str(round(float(item['rating']),1)) })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Playcount": item['playcount'] })
|
||||||
|
if "director" in item:
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Director": " / ".join(item['director']) })
|
||||||
|
if "writer" in item:
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Writer": " / ".join(item['writer']) })
|
||||||
|
if "cast" in item:
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "Cast": cast[0] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "CastAndRole": cast[1] })
|
||||||
|
liz.setProperty("episodeno", episodeno)
|
||||||
|
liz.setProperty("resumetime", str(item['resume']['position']))
|
||||||
|
liz.setProperty("totaltime", str(item['resume']['total']))
|
||||||
|
liz.setArt(item['art'])
|
||||||
|
liz.setThumbnailImage(item['art'].get('thumb',''))
|
||||||
|
liz.setIconImage('DefaultTVShows.png')
|
||||||
|
liz.setProperty("dbid", str(item['episodeid']))
|
||||||
|
liz.setProperty("fanart_image", item['art'].get('tvshow.fanart',''))
|
||||||
|
for key, value in item['streamdetails'].iteritems():
|
||||||
|
for stream in value:
|
||||||
|
liz.addStreamInfo( key, stream )
|
||||||
|
|
||||||
|
return liz
|
||||||
|
|
||||||
##### GET EXTRAFANART FOR LISTITEM #####
|
##### GET EXTRAFANART FOR LISTITEM #####
|
||||||
def getExtraFanArt():
|
def getExtraFanArt():
|
||||||
|
|
|
@ -149,19 +149,13 @@ class VideoNodes():
|
||||||
if type == "tvshows":
|
if type == "tvshows":
|
||||||
#create tag node - recent episodes
|
#create tag node - recent episodes
|
||||||
nodefile = os.path.join(libraryPath, tagname + "_recent_episodes.xml")
|
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)
|
label = language(30175)
|
||||||
etree.SubElement(root, "label").text = label
|
etree.SubElement(root, "label").text = label
|
||||||
etree.SubElement(root, "match").text = "all"
|
|
||||||
etree.SubElement(root, "content").text = "episodes"
|
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, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
||||||
etree.SubElement(root, "order", {"direction":"descending"}).text = "dateadded"
|
path = "plugin://plugin.video.emby/?id=%s&mode=recentepisodes&limit=25" %tagname
|
||||||
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
etree.SubElement(root, "path").text = path
|
||||||
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)
|
WINDOW.setProperty("Emby.nodes.%s.recentepisodes.title" %str(windowPropId),label)
|
||||||
path = "library://video/Emby - %s/%s_recent_episodes.xml"%(tagname,tagname)
|
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)
|
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
|
#create tag node - inprogress items
|
||||||
nodefile = os.path.join(libraryPath, tagname + "_progress_episodes.xml")
|
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)
|
label = language(30178)
|
||||||
etree.SubElement(root, "label").text = label
|
etree.SubElement(root, "label").text = label
|
||||||
etree.SubElement(root, "match").text = "all"
|
|
||||||
etree.SubElement(root, "content").text = "episodes"
|
etree.SubElement(root, "content").text = "episodes"
|
||||||
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
etree.SubElement(root, "icon").text = "special://home/addons/plugin.video.emby/icon.png"
|
||||||
etree.SubElement(root, "path").text = nodefile_root
|
path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25" %tagname
|
||||||
#set limit to 25 --> currently hardcoded --> TODO: add a setting for this ?
|
etree.SubElement(root, "path").text = path
|
||||||
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)
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.title" %str(windowPropId),label)
|
||||||
path = "library://video/Emby - %s/%s_progress_episodes.xml"%(tagname,tagname)
|
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)
|
WINDOW.setProperty("Emby.nodes.%s.inprogressepisodes.path" %str(windowPropId),"ActivateWindow(Video,%s,return)"%path)
|
||||||
|
|
Loading…
Reference in a new issue