Revert "Fixes to listitem setup"

This reverts commit f2dd8617f3.
This commit is contained in:
tomkat83 2016-04-19 15:20:03 +02:00
parent f2dd8617f3
commit 133482001c
2 changed files with 33 additions and 83 deletions

View file

@ -37,7 +37,6 @@ import xml.etree.ElementTree as etree
import re
import json
from urllib import urlencode, quote_plus, unquote
import requests
import xbmcaddon
import xbmcgui
@ -47,7 +46,7 @@ import xbmcvfs
import clientinfo
import utils
import downloadutils
import embydb_functions as embydb
import requests
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
@ -2146,31 +2145,13 @@ class API():
Returns XBMC listitem for this PMS library item
"""
people = self.getPeople()
userdata = self.getUserData()
title, sorttitle = self.getTitle()
if listItem is None:
listItem = xbmcgui.ListItem(title)
else:
listItem.setLabel(title)
listItem = xbmcgui.ListItem()
listItem.setProperty('IsPlayable', 'true')
listItem.setProperty('IsFolder', 'false')
typus = self.getType()
if typus == 'movie':
listItem.setProperty('DBTYPE', 'movie')
elif typus == 'episode':
listItem.setProperty('DBTYPE', 'episode')
with embydb.GetEmbyDB() as emby_db:
try:
dbid = emby_db.getItem_byId(self.getRatingKey())[0]
listItem.setProperty('dbid', str(dbid))
except TypeError:
pass
self.logMsg('ratingKey: %s, dbid: %s' % (self.getRatingKey(), str(dbid)))
people = self.getPeople()
userdata = self.getUserData()
metadata = {
'genre': self.joinList(self.getGenres()),
'year': self.getYear(),
@ -2179,6 +2160,7 @@ class API():
'cast': people['Cast'],
'director': self.joinList(people.get('Director')),
'plot': self.getPlot(),
'title': title,
'sorttitle': sorttitle,
'duration': userdata['Runtime'],
'studio': self.joinList(self.getStudios()),
@ -2190,38 +2172,24 @@ class API():
'mpaa': self.getMpaa(),
'aired': self.getPremiereDate()
}
if userdata['Resume'] > 0:
listItem.setProperty('resumetime', str(userdata['Resume']))
if userdata['Runtime'] > 0:
listItem.setProperty('totaltime', str(userdata['Runtime']))
try:
PercentPlayed = userdata['Resume'] / userdata['Runtime'] * 100.0
except ZeroDivisionError:
PercentPlayed = 0.0
if PercentPlayed > 0:
metadata['PercentPlayed'] = PercentPlayed
if self.getType() == "episode":
# Only for tv shows
key, show, season, episode = self.getEpisodeDetails()
metadata['episode'] = int(episode)
metadata['season'] = int(season)
metadata['episode'] = episode
metadata['season'] = season
metadata['tvshowtitle'] = show
try:
listItem.setProperty('episodeno', "s%.2de%.2d"
% (int(season), int(episode)))
except:
pass
listItem.setIconImage('DefaultTVShows.png')
elif self.getType() == "movie":
listItem.setIconImage('DefaultMovies.png')
elif self.getType() == "clip":
listItem.setIconImage('DefaultVideo.png')
artwork = self.getAllArtwork()
if artwork.get('Primary'):
listItem.setThumbnailImage(artwork.get('Primary'))
elif self.getType() == "movie":
listItem.setThumbnailImage('DefaultMovies.png')
elif self.getType() == "episode":
listItem.setThumbnailImage('DefaultTVShows.png')
# Very resource intensive
listItem.setProperty('IsPlayable', 'true')
listItem.setProperty('IsFolder', 'false')
listItem.setProperty('embyid', self.getRatingKey())
listItem.setLabel(title)
listItem.setInfo('video', infoLabels=metadata)
return listItem

View file

@ -1031,7 +1031,6 @@ def createListItem(item):
li.setIconImage('DefaultTVShows.png')
li.setProperty('dbid', str(item['episodeid']))
li.setProperty('fanart_image', item['art'].get('tvshow.fanart',''))
li.setLabel(title)
for key, value in item['streamdetails'].iteritems():
for stream in value:
li.addStreamInfo(key, stream)
@ -1492,12 +1491,6 @@ def getOnDeck(viewid, mediatype, tagname, limit):
if counter >= 300:
break
xbmc.sleep(100)
# Wait till full lib sync done
while utils.window('emby_dbScan') == 'true':
counter += 1
if counter >= 300:
break
xbmc.sleep(100)
xml = downloadutils.DownloadUtils().downloadUrl(
'{server}/library/sections/%s/onDeck' % viewid)
if xml in (None, 401):
@ -1506,34 +1499,23 @@ def getOnDeck(viewid, mediatype, tagname, limit):
params = {
'mode': "play"
}
counter = 0
for item in xml:
counter += 1
if counter > 1:
break
API = PlexAPI.API(item)
listitem = API.CreateListItemFromPlexItem()
pbutils.PlaybackUtils(item).setArtwork(listitem)
API.AddStreamInfo(listitem)
plexID = API.getRatingKey()
with embydb.GetEmbyDB() as emby_db:
with embydb.GetEmbyDB() as emby_db:
for item in xml:
API = PlexAPI.API(item)
listitem = API.CreateListItemFromPlexItem()
API.AddStreamInfo(listitem)
pbutils.PlaybackUtils(item).setArtwork(listitem)
plexID = API.getRatingKey()
try:
dbid = emby_db.getItem_byId(plexID)[0]
except TypeError:
dbid = None
params['id'] = plexID
params['dbid'] = dbid
path = "%s?%s" % (url, urllib.urlencode(params))
listitem.setProperty('path', path)
listitem.setProperty('file', path)
listitem.setProperty('FileNameAndPath', path)
props = ('dbid', 'DBTYPE', 'path',)
for thing in props:
utils.logMsg('%s: %s' % (thing, listitem.getProperty(thing)), 1)
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url=path,
listitem=listitem)
params['id'] = plexID
params['dbid'] = dbid
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url="%s?%s" % (url, urllib.urlencode(params)),
listitem=listitem)
return xbmcplugin.endOfDirectory(
handle=int(sys.argv[1]),
cacheToDisc=True if utils.settings('enableTextureCache') == 'true'
@ -1628,7 +1610,7 @@ def getOnDeck(viewid, mediatype, tagname, limit):
continue
for episode in episodes:
# There will always be only 1 episode ('limit=1')
listitem = createListItem(episode)
li = createListItem(episode)
# Fix some skin shortcomings
title = episode.get('title', '')
if utils.settings('OnDeckTvAppendSeason') == 'true':
@ -1641,11 +1623,11 @@ def getOnDeck(viewid, mediatype, tagname, limit):
show = episode.get('showtitle')
if show:
title = show + ' - ' + title
listitem.setLabel(title)
li.setLabel(title)
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url=episode['file'],
listitem=listitem,
listitem=li,
isFolder=False)
count += 1