add more info to now playing items

This commit is contained in:
Shaun
2018-01-03 11:53:24 +11:00
parent 2e9c230314
commit ea3932d569
2 changed files with 60 additions and 7 deletions

View File

@@ -211,8 +211,8 @@ def playFile(play_info):
def setListItemProps(id, listItem, result, server, extra_props, title):
# set up item and item info
thumbID = id
eppNum = -1
seasonNum = -1
episode_number = -1
season_number = -1
art = getArt(result, server=server)
listItem.setIconImage(art['thumb']) # back compat
@@ -227,17 +227,44 @@ def setListItemProps(id, listItem, result, server, extra_props, title):
for prop in extra_props:
listItem.setProperty(prop[0], prop[1])
item_type = result.get("Type", "").lower()
mediatype = 'video'
if item_type == 'movie' or item_type == 'boxset':
mediatype = 'movie'
elif item_type == 'series':
mediatype = 'tvshow'
elif item_type == 'season':
mediatype = 'season'
elif item_type == 'episode':
mediatype = 'episode'
if item_type == "episode":
episode_number = result.get("IndexNumber", -1)
if item_type == "episode":
season_number = result.get("ParentIndexNumber", -1)
elif item_type == "season":
season_number = result.get("IndexNumber", -1)
# play info
details = {
'title': title,
'plot': result.get("Overview")
'plot': result.get("Overview"),
'mediatype': mediatype
}
if (eppNum > -1):
details["episode"] = str(eppNum)
tv_show_name = result.get("SeriesName")
if tv_show_name is not None:
details['tvshowtitle'] = tv_show_name
if (seasonNum > -1):
details["season"] = str(seasonNum)
if episode_number > -1:
details["episode"] = str(episode_number)
if season_number > -1:
details["season"] = str(season_number)
listItem.setUniqueIDs({'emby': id})
listItem.setInfo("Video", infoLabels=details)

View File

@@ -315,6 +315,30 @@ remote_control = settings.getSetting('remoteControl') == "true"
if remote_control:
websocket_client.start()
'''
def getNowPlaying():
# Get the active player
result = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
result = unicode(result, 'utf-8', errors='ignore')
log.debug("Got active player: {0}", result)
result = json.loads(result)
if 'result' in result and len(result["result"]) > 0:
playerid = result["result"][0]["playerid"]
# Get details of the playing media
log.debug("Getting details of now playing media")
result = xbmc.executeJSONRPC(
'{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"playerid": ' + str(
playerid) + ', "properties": ["showtitle", "tvshowid", "episode", "season", "playcount", "genre", "uniqueid"] } }')
result = unicode(result, 'utf-8', errors='ignore')
log.debug("playing_item_details: {0}", result)
result = json.loads(result)
return result
'''
# monitor.abortRequested() is causes issues, it currently triggers for all addon cancelations which causes
# the service to exit when a user cancels an addon load action. This is a bug in Kodi.
# I am switching back to xbmc.abortRequested approach until kodi is fixed or I find a work arround
@@ -340,6 +364,8 @@ while not xbmc.abortRequested:
last_content_check = time.time()
checkForNewContent()
#getNowPlaying()
except Exception as error:
log.error("Exception in Playback Monitor: {0}", error)
log.error("{0}", traceback.format_exc())