This commit is contained in:
Croneter 2018-06-15 13:55:32 +02:00
parent f427210f14
commit c14b9b4ed8

View file

@ -200,19 +200,19 @@ def switch_plex_user():
__LogIn() __LogIn()
##### LISTITEM SETUP FOR VIDEONODES ##### def create_listitem(item, append_show_title=False, append_sxxexx=False):
def createListItem(item, append_show_title=False, append_sxxexx=False): """
LOG.debug('createListItem called with append_show_title %s, append_sxxexx ' Feed with a Kodi json item response to get a xbmcgui.ListItem() with
'%s, item: %s', append_show_title, append_sxxexx, item) everything set and ready.
"""
title = item['title'] title = item['title']
li = ListItem(title) listitem = ListItem(title)
li.setProperty('IsPlayable', 'true') listitem.setProperty('IsPlayable', 'true')
metadata = { metadata = {
'duration': str(item['runtime'] / 60), 'duration': str(item['runtime'] / 60),
'Plot': item['plot'], 'Plot': item['plot'],
'Playcount': item['playcount'] 'Playcount': item['playcount']
} }
if 'episode' in item: if 'episode' in item:
episode = item['episode'] episode = item['episode']
metadata['Episode'] = episode metadata['Episode'] = episode
@ -220,7 +220,7 @@ def createListItem(item, append_show_title=False, append_sxxexx=False):
season = item['season'] season = item['season']
metadata['Season'] = season metadata['Season'] = season
if season and episode: if season and episode:
li.setProperty('episodeno', 's%.2de%.2d' % (season, episode)) listitem.setProperty('episodeno', 's%.2de%.2d' % (season, episode))
if append_sxxexx is True: if append_sxxexx is True:
title = 'S%.2dE%.2d - %s' % (season, episode, title) title = 'S%.2dE%.2d - %s' % (season, episode, title)
if 'firstaired' in item: if 'firstaired' in item:
@ -248,24 +248,25 @@ def createListItem(item, append_show_title=False, append_sxxexx=False):
metadata['Title'] = title metadata['Title'] = title
metadata['mediatype'] = 'episode' metadata['mediatype'] = 'episode'
metadata['dbid'] = str(item['episodeid']) metadata['dbid'] = str(item['episodeid'])
li.setLabel(title) listitem.setLabel(title)
li.setInfo(type='Video', infoLabels=metadata) listitem.setInfo(type='Video', infoLabels=metadata)
li.setProperty('resumetime', str(item['resume']['position'])) listitem.setProperty('resumetime', str(item['resume']['position']))
li.setProperty('totaltime', str(item['resume']['total'])) listitem.setProperty('totaltime', str(item['resume']['total']))
li.setArt(item['art']) listitem.setArt(item['art'])
li.setThumbnailImage(item['art'].get('thumb', '')) listitem.setThumbnailImage(item['art'].get('thumb', ''))
li.setArt({'icon': 'DefaultTVShows.png'}) listitem.setArt({'icon': 'DefaultTVShows.png'})
li.setProperty('fanart_image', item['art'].get('tvshow.fanart', '')) listitem.setProperty('fanart_image', item['art'].get('tvshow.fanart', ''))
try: try:
li.addContextMenuItems([(lang(30032), 'XBMC.Action(Info)',)]) listitem.addContextMenuItems([(lang(30032), 'XBMC.Action(Info)',)])
except TypeError: except TypeError:
# Kodi fuck-up # Kodi fuck-up
pass pass
for key, value in item['streamdetails'].iteritems(): for key, value in item['streamdetails'].iteritems():
for stream in value: for stream in value:
li.addStreamInfo(key, stream) listitem.addStreamInfo(key, stream)
return li return listitem
##### GET NEXTUP EPISODES FOR TAGNAME ##### ##### GET NEXTUP EPISODES FOR TAGNAME #####
def getNextUpEpisodes(tagname, limit): def getNextUpEpisodes(tagname, limit):
@ -323,7 +324,7 @@ def getNextUpEpisodes(tagname, limit):
for episode in js.get_episodes(params): for episode in js.get_episodes(params):
xbmcplugin.addDirectoryItem(handle=HANDLE, xbmcplugin.addDirectoryItem(handle=HANDLE,
url=episode['file'], url=episode['file'],
listitem=createListItem(episode)) listitem=create_listitem(episode))
count += 1 count += 1
if count == limit: if count == limit:
break break
@ -362,7 +363,7 @@ def getInProgressEpisodes(tagname, limit):
for episode in js.get_episodes(params): for episode in js.get_episodes(params):
xbmcplugin.addDirectoryItem(handle=HANDLE, xbmcplugin.addDirectoryItem(handle=HANDLE,
url=episode['file'], url=episode['file'],
listitem=createListItem(episode)) listitem=create_listitem(episode))
count += 1 count += 1
if count == limit: if count == limit:
break break
@ -401,11 +402,10 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit):
} }
for episode in js.get_episodes(params): for episode in js.get_episodes(params):
if episode['tvshowid'] in allshowsIds: if episode['tvshowid'] in allshowsIds:
listitem = createListItem(episode, listitem = create_listitem(episode,
append_show_title=append_show_title, append_show_title=append_show_title,
append_sxxexx=append_sxxexx) append_sxxexx=append_sxxexx)
xbmcplugin.addDirectoryItem( xbmcplugin.addDirectoryItem(handle=HANDLE,
handle=HANDLE,
url=episode['file'], url=episode['file'],
listitem=listitem) listitem=listitem)
count += 1 count += 1
@ -641,7 +641,7 @@ def getOnDeck(viewid, mediatype, tagname, limit):
continue continue
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')
listitem = createListItem(episode, listitem = create_listitem(episode,
append_show_title=append_show_title, append_show_title=append_show_title,
append_sxxexx=append_sxxexx) append_sxxexx=append_sxxexx)
xbmcplugin.addDirectoryItem(handle=HANDLE, xbmcplugin.addDirectoryItem(handle=HANDLE,