Video Node: recently added episodes
This commit is contained in:
parent
05c902434b
commit
76464a898f
3 changed files with 50 additions and 56 deletions
|
@ -90,7 +90,7 @@ class Main:
|
||||||
# modes[mode](itemid, dbid)
|
# modes[mode](itemid, dbid)
|
||||||
modes[mode](itemid, dbid)
|
modes[mode](itemid, dbid)
|
||||||
|
|
||||||
elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
|
elif mode in ("nextup", "inprogressepisodes"):
|
||||||
limit = int(params['limit'][0])
|
limit = int(params['limit'][0])
|
||||||
modes[mode](itemid, limit)
|
modes[mode](itemid, limit)
|
||||||
|
|
||||||
|
@ -106,12 +106,12 @@ class Main:
|
||||||
params.get('type', [""])[0],
|
params.get('type', [""])[0],
|
||||||
params.get('folderid', [""])[0])
|
params.get('folderid', [""])[0])
|
||||||
|
|
||||||
elif mode == 'ondeck':
|
elif mode in ('ondeck', 'recentepisodes'):
|
||||||
modes[mode](
|
modes[mode](
|
||||||
itemid,
|
itemid,
|
||||||
params.get('type', [""])[0],
|
params.get('type', [""])[0],
|
||||||
params.get('tagname', [""])[0],
|
params.get('tagname', [""])[0],
|
||||||
params.get('limit', [""])[0])
|
int(params.get('limit', [""])[0]))
|
||||||
|
|
||||||
elif mode == "channelsfolder":
|
elif mode == "channelsfolder":
|
||||||
folderid = params['folderid'][0]
|
folderid = params['folderid'][0]
|
||||||
|
|
|
@ -1113,44 +1113,41 @@ def getInProgressEpisodes(tagname, limit):
|
||||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
|
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
|
||||||
|
|
||||||
##### GET RECENT EPISODES FOR TAGNAME #####
|
##### GET RECENT EPISODES FOR TAGNAME #####
|
||||||
def getRecentEpisodes(tagname, limit):
|
# def getRecentEpisodes(tagname, limit):
|
||||||
|
def getRecentEpisodes(viewid, mediatype, tagname, limit):
|
||||||
count = 0
|
count = 0
|
||||||
# if the addon is called with recentepisodes parameter,
|
# if the addon is called with recentepisodes parameter,
|
||||||
# we return the recentepisodes list of the given tagname
|
# we return the recentepisodes list of the given tagname
|
||||||
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
|
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
|
||||||
# First we get a list of all the TV shows - filtered by tag
|
# First we get a list of all the TV shows - filtered by tag
|
||||||
query = {
|
query = {
|
||||||
|
|
||||||
'jsonrpc': "2.0",
|
'jsonrpc': "2.0",
|
||||||
'id': "libTvShows",
|
'id': "libTvShows",
|
||||||
'method': "VideoLibrary.GetTVShows",
|
'method': "VideoLibrary.GetTVShows",
|
||||||
'params': {
|
'params': {
|
||||||
|
|
||||||
'sort': {'order': "descending", 'method': "dateadded"},
|
'sort': {'order': "descending", 'method': "dateadded"},
|
||||||
'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname},
|
'filter': {'operator': "is", 'field': "tag", 'value': "%s" % tagname},
|
||||||
'properties': ["title","sorttitle"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = xbmc.executeJSONRPC(json.dumps(query))
|
result = xbmc.executeJSONRPC(json.dumps(query))
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
# If we found any, find the oldest unwatched show for each one.
|
# If we found any, find the oldest unwatched show for each one.
|
||||||
try:
|
try:
|
||||||
items = result['result']['tvshows']
|
items = result['result'][mediatype]
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
pass
|
# No items, empty folder
|
||||||
else:
|
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
|
||||||
|
return
|
||||||
|
|
||||||
allshowsIds = set()
|
allshowsIds = set()
|
||||||
for item in items:
|
for item in items:
|
||||||
allshowsIds.add(item['tvshowid'])
|
allshowsIds.add(item['tvshowid'])
|
||||||
|
|
||||||
query = {
|
query = {
|
||||||
|
|
||||||
'jsonrpc': "2.0",
|
'jsonrpc': "2.0",
|
||||||
'id': 1,
|
'id': 1,
|
||||||
'method': "VideoLibrary.GetEpisodes",
|
'method': "VideoLibrary.GetEpisodes",
|
||||||
'params': {
|
'params': {
|
||||||
|
|
||||||
'sort': {'order': "descending", 'method': "dateadded"},
|
'sort': {'order': "descending", 'method': "dateadded"},
|
||||||
'filter': {'operator': "lessthan", 'field': "playcount", 'value': "1"},
|
'filter': {'operator': "lessthan", 'field': "playcount", 'value': "1"},
|
||||||
'properties': [
|
'properties': [
|
||||||
|
@ -1352,7 +1349,7 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
mediatype: Kodi mediatype, e.g. 'tvshows', 'movies',
|
mediatype: Kodi mediatype, e.g. 'tvshows', 'movies',
|
||||||
'homevideos', 'photos'
|
'homevideos', 'photos'
|
||||||
tagname: Name of the Plex library, e.g. "My Movies"
|
tagname: Name of the Plex library, e.g. "My Movies"
|
||||||
limit: Max. number of items to retrieve, e.g. '50'
|
limit: Max. number of items to retrieve, e.g. 50
|
||||||
"""
|
"""
|
||||||
# if the addon is called with nextup parameter,
|
# if the addon is called with nextup parameter,
|
||||||
# we return the nextepisodes list of the given tagname
|
# we return the nextepisodes list of the given tagname
|
||||||
|
@ -1373,7 +1370,6 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
}
|
}
|
||||||
result = xbmc.executeJSONRPC(json.dumps(query))
|
result = xbmc.executeJSONRPC(json.dumps(query))
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
utils.logMsg('test', 'result: %s' % result, 1)
|
|
||||||
# If we found any, find the oldest unwatched show for each one.
|
# If we found any, find the oldest unwatched show for each one.
|
||||||
try:
|
try:
|
||||||
items = result['result'][mediatype]
|
items = result['result'][mediatype]
|
||||||
|
@ -1431,7 +1427,6 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
inprogrQuery['params']['tvshowid'] = item['tvshowid']
|
inprogrQuery['params']['tvshowid'] = item['tvshowid']
|
||||||
result = xbmc.executeJSONRPC(json.dumps(inprogrQuery))
|
result = xbmc.executeJSONRPC(json.dumps(inprogrQuery))
|
||||||
result = json.loads(result)
|
result = json.loads(result)
|
||||||
utils.logMsg('test', 'result: %s' % result, 1)
|
|
||||||
try:
|
try:
|
||||||
episodes = result['result']['episodes']
|
episodes = result['result']['episodes']
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
|
@ -1444,10 +1439,8 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
except (KeyError, TypeError):
|
except (KeyError, TypeError):
|
||||||
# Also no episodes currently coming up
|
# Also no episodes currently coming up
|
||||||
continue
|
continue
|
||||||
utils.logMsg('test', 'results: %s' % episodes, 1)
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# There will always be only 1 episode ('limit=1')
|
# There will always be only 1 episode ('limit=1')
|
||||||
utils.logMsg('test', 'episode: %s' % episode, 1)
|
|
||||||
li = createListItem(episode)
|
li = createListItem(episode)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
|
|
|
@ -226,9 +226,11 @@ class VideoNodes(object):
|
||||||
elif nodetype == "nextepisodes":
|
elif nodetype == "nextepisodes":
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=nextup&limit=%s" % (tagname, limit)
|
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=nextup&limit=%s" % (tagname, limit)
|
||||||
elif kodiversion == 14 and nodetype == "recentepisodes":
|
# elif kodiversion == 14 and nodetype == "recentepisodes":
|
||||||
|
elif nodetype == "recentepisodes":
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=recentepisodes&limit=%s" % (tagname, limit)
|
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=recentepisodes&type=%s&tagname=%s&limit=%s"
|
||||||
|
% (viewid, mediatype, tagname, limit))
|
||||||
elif kodiversion == 14 and nodetype == "inprogressepisodes":
|
elif kodiversion == 14 and nodetype == "inprogressepisodes":
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=%s" % (tagname, limit)
|
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=inprogressepisodes&limit=%s" % (tagname, limit)
|
||||||
|
@ -277,8 +279,7 @@ class VideoNodes(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Create the root
|
# Create the root
|
||||||
if (nodetype in ("nextepisodes", "ondeck") or mediatype == "homevideos" or
|
if (nodetype in ("nextepisodes", "ondeck", 'recentepisodes') or mediatype == "homevideos"):
|
||||||
(kodiversion == 14 and nodetype in ('recentepisodes', 'inprogressepisodes'))):
|
|
||||||
# Folder type with plugin path
|
# Folder type with plugin path
|
||||||
root = self.commonRoot(order=sortorder[node], label=label, tagname=tagname, roottype=2)
|
root = self.commonRoot(order=sortorder[node], label=label, tagname=tagname, roottype=2)
|
||||||
etree.SubElement(root, 'path').text = path
|
etree.SubElement(root, 'path').text = path
|
||||||
|
|
Loading…
Reference in a new issue