Fix TV show on deck view
- Fix TV show poster for episodes - Added banner to setArtwork - Cleaned up getAllArtwork
This commit is contained in:
parent
119ad79f0f
commit
0c880cd883
3 changed files with 73 additions and 90 deletions
|
@ -48,6 +48,7 @@ import utils
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import requests
|
import requests
|
||||||
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
|
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
|
||||||
|
import embydb_functions as embydb
|
||||||
|
|
||||||
|
|
||||||
@utils.logging
|
@utils.logging
|
||||||
|
@ -1803,33 +1804,38 @@ class API():
|
||||||
'subtitle': subtitlelanguages
|
'subtitle': subtitlelanguages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __getOneArtwork(self, entry):
|
||||||
|
try:
|
||||||
|
artwork = self.item.attrib[entry]
|
||||||
|
if artwork.startswith('http'):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
artwork = "%s%s" % (self.server, artwork)
|
||||||
|
artwork = self.addPlexCredentialsToUrl(artwork)
|
||||||
|
except KeyError:
|
||||||
|
artwork = ""
|
||||||
|
return artwork
|
||||||
|
|
||||||
def getAllArtwork(self, parentInfo=False):
|
def getAllArtwork(self, parentInfo=False):
|
||||||
"""
|
"""
|
||||||
Gets the URLs to the Plex artwork, or empty string if not found.
|
Gets the URLs to the Plex artwork, or empty string if not found.
|
||||||
|
parentInfo=True will check for parent's artwork if None is found
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
{
|
{
|
||||||
'Primary': Plex key: "thumb". Only 1 pix
|
'Primary' : xml key 'thumb'
|
||||||
'Art':,
|
'Art' : always ''
|
||||||
'Banner':,
|
'Banner' : xml key 'banner'
|
||||||
'Logo':,
|
'Logo' : always ''
|
||||||
'Thumb':,
|
'Thumb' : xml key 'grandparentThumb'
|
||||||
'Disc':,
|
'Disc' : always ''
|
||||||
'Backdrop': [] Plex key: "art". Only 1 pix
|
'Backdrop' : LIST with ONE xml key "art"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
item = self.item.attrib
|
item = self.item.attrib
|
||||||
|
|
||||||
# maxHeight = 10000
|
|
||||||
# maxWidth = 10000
|
|
||||||
# customquery = ""
|
|
||||||
|
|
||||||
# if utils.settings('compressArt') == "true":
|
|
||||||
# customquery = "&Quality=90"
|
|
||||||
|
|
||||||
# if utils.settings('enableCoverArt') == "false":
|
|
||||||
# customquery += "&EnableImageEnhancers=false"
|
|
||||||
|
|
||||||
allartworks = {
|
allartworks = {
|
||||||
'Primary': "",
|
'Primary': "",
|
||||||
'Art': "",
|
'Art': "",
|
||||||
|
@ -1841,44 +1847,22 @@ class API():
|
||||||
}
|
}
|
||||||
# Process backdrops
|
# Process backdrops
|
||||||
# Get background artwork URL
|
# Get background artwork URL
|
||||||
try:
|
allartworks['Backdrop'].append(self.__getOneArtwork('art'))
|
||||||
background = item['art']
|
|
||||||
if background.startswith('http'):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
background = "%s%s" % (self.server, background)
|
|
||||||
background = self.addPlexCredentialsToUrl(background)
|
|
||||||
except KeyError:
|
|
||||||
background = ""
|
|
||||||
allartworks['Backdrop'].append(background)
|
|
||||||
# Get primary "thumb" pictures:
|
# Get primary "thumb" pictures:
|
||||||
try:
|
allartworks['Primary'] = self.__getOneArtwork('thumb')
|
||||||
primary = item['thumb']
|
# Banner (usually only on tv series level)
|
||||||
if primary.startswith('http'):
|
allartworks['Banner'] = self.__getOneArtwork('banner')
|
||||||
pass
|
# For e.g. TV shows, get series thumb
|
||||||
else:
|
allartworks['Thumb'] = self.__getOneArtwork('grandparentThumb')
|
||||||
primary = "%s%s" % (self.server, primary)
|
|
||||||
primary = self.addPlexCredentialsToUrl(primary)
|
|
||||||
except KeyError:
|
|
||||||
primary = ""
|
|
||||||
allartworks['Primary'] = primary
|
|
||||||
|
|
||||||
# Process parent items if the main item is missing artwork
|
# Process parent items if the main item is missing artwork
|
||||||
if parentInfo:
|
if parentInfo:
|
||||||
# Process parent backdrops
|
# Process parent backdrops
|
||||||
if not allartworks['Backdrop']:
|
if not allartworks['Backdrop']:
|
||||||
background = item.get('parentArt')
|
allartworks['Backdrop'].append(
|
||||||
if background:
|
self.__getOneArtwork('parentArt'))
|
||||||
background = "%s%s" % (self.server, background)
|
|
||||||
background = self.addPlexCredentialsToUrl(background)
|
|
||||||
allartworks['Backdrop'].append(background)
|
|
||||||
|
|
||||||
if not allartworks['Primary']:
|
if not allartworks['Primary']:
|
||||||
primary = item.get('parentThumb')
|
allartworks['Primary'] = self.__getOneArtwork('parentThumb')
|
||||||
if primary:
|
|
||||||
primary = "%s%s" % (self.server, primary)
|
|
||||||
primary = self.addPlexCredentialsToUrl(primary)
|
|
||||||
allartworks['Primary'] = primary
|
|
||||||
return allartworks
|
return allartworks
|
||||||
|
|
||||||
# TO BE DONE
|
# TO BE DONE
|
||||||
|
@ -2150,7 +2134,8 @@ class API():
|
||||||
title, sorttitle = self.getTitle()
|
title, sorttitle = self.getTitle()
|
||||||
|
|
||||||
if listItem is None:
|
if listItem is None:
|
||||||
listItem = xbmcgui.ListItem()
|
listItem = xbmcgui.ListItem(title)
|
||||||
|
listItem.setProperty('IsPlayable', 'true')
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'genre': self.joinList(self.getGenres()),
|
'genre': self.joinList(self.getGenres()),
|
||||||
|
@ -2176,14 +2161,31 @@ class API():
|
||||||
if self.getType() == "episode":
|
if self.getType() == "episode":
|
||||||
# Only for tv shows
|
# Only for tv shows
|
||||||
key, show, season, episode = self.getEpisodeDetails()
|
key, show, season, episode = self.getEpisodeDetails()
|
||||||
|
season = -1 if season is None else int(season)
|
||||||
|
episode = -1 if episode is None else int(episode)
|
||||||
metadata['episode'] = episode
|
metadata['episode'] = episode
|
||||||
metadata['season'] = season
|
metadata['season'] = season
|
||||||
metadata['tvshowtitle'] = show
|
metadata['tvshowtitle'] = show
|
||||||
|
if season and episode:
|
||||||
|
listItem.setProperty('episodeno',
|
||||||
|
"s%.2de%.2d" % (season, episode))
|
||||||
|
listItem.setIconImage('DefaultTVShows.png')
|
||||||
|
elif self.getType() == "movie":
|
||||||
|
listItem.setIconImage('DefaultMovies.png')
|
||||||
|
else:
|
||||||
|
listItem.setIconImage('DefaultVideo.png')
|
||||||
|
|
||||||
listItem.setProperty('IsPlayable', 'true')
|
listItem.setProperty('resumetime', str(userdata['Resume']))
|
||||||
listItem.setProperty('IsFolder', 'false')
|
listItem.setProperty('totaltime', str(userdata['Runtime']))
|
||||||
listItem.setProperty('embyid', self.getRatingKey())
|
plexId = self.getRatingKey()
|
||||||
listItem.setLabel(title)
|
listItem.setProperty('embyid', plexId)
|
||||||
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
|
try:
|
||||||
|
listItem.setProperty('dbid',
|
||||||
|
str(emby_db.getItem_byId(plexId)[0]))
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
# Expensive operation
|
||||||
listItem.setInfo('video', infoLabels=metadata)
|
listItem.setInfo('video', infoLabels=metadata)
|
||||||
return listItem
|
return listItem
|
||||||
|
|
||||||
|
|
|
@ -1499,19 +1499,13 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
params = {
|
params = {
|
||||||
'mode': "play"
|
'mode': "play"
|
||||||
}
|
}
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
|
||||||
for item in xml:
|
for item in xml:
|
||||||
API = PlexAPI.API(item)
|
API = PlexAPI.API(item)
|
||||||
listitem = API.CreateListItemFromPlexItem()
|
listitem = API.CreateListItemFromPlexItem()
|
||||||
API.AddStreamInfo(listitem)
|
API.AddStreamInfo(listitem)
|
||||||
pbutils.PlaybackUtils(item).setArtwork(listitem)
|
pbutils.PlaybackUtils(item).setArtwork(listitem)
|
||||||
plexID = API.getRatingKey()
|
params['id'] = API.getRatingKey()
|
||||||
try:
|
params['dbid'] = listitem.getProperty('dbid')
|
||||||
dbid = emby_db.getItem_byId(plexID)[0]
|
|
||||||
except TypeError:
|
|
||||||
dbid = None
|
|
||||||
params['id'] = plexID
|
|
||||||
params['dbid'] = dbid
|
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
url="%s?%s" % (url, urllib.urlencode(params)),
|
url="%s?%s" % (url, urllib.urlencode(params)),
|
||||||
|
|
|
@ -327,22 +327,9 @@ class PlaybackUtils():
|
||||||
|
|
||||||
def setArtwork(self, listItem):
|
def setArtwork(self, listItem):
|
||||||
allartwork = self.API.getAllArtwork(parentInfo=True)
|
allartwork = self.API.getAllArtwork(parentInfo=True)
|
||||||
|
|
||||||
# arttypes = {
|
|
||||||
|
|
||||||
# 'poster': "Primary",
|
|
||||||
# 'tvshow.poster': "Primary",
|
|
||||||
# 'clearart': "Art",
|
|
||||||
# 'tvshow.clearart': "Art",
|
|
||||||
# 'clearlogo': "Logo",
|
|
||||||
# 'tvshow.clearlogo': "Logo",
|
|
||||||
# 'discart': "Disc",
|
|
||||||
# 'fanart_image': "Backdrop",
|
|
||||||
# 'landscape': "Thumb"
|
|
||||||
# }
|
|
||||||
arttypes = {
|
arttypes = {
|
||||||
'poster': "Primary",
|
'poster': "Primary",
|
||||||
'tvshow.poster': "Primary",
|
'tvshow.poster': "Thumb",
|
||||||
'clearart': "Art",
|
'clearart': "Art",
|
||||||
'tvshow.clearart': "Art",
|
'tvshow.clearart': "Art",
|
||||||
'clearart': "Primary",
|
'clearart': "Primary",
|
||||||
|
@ -351,25 +338,25 @@ class PlaybackUtils():
|
||||||
'tvshow.clearlogo': "Logo",
|
'tvshow.clearlogo': "Logo",
|
||||||
'discart': "Disc",
|
'discart': "Disc",
|
||||||
'fanart_image': "Backdrop",
|
'fanart_image': "Backdrop",
|
||||||
'landscape': "Backdrop"
|
'landscape': "Backdrop",
|
||||||
|
"banner": "Banner"
|
||||||
}
|
}
|
||||||
for arttype in arttypes:
|
for arttype in arttypes:
|
||||||
|
|
||||||
art = arttypes[arttype]
|
art = arttypes[arttype]
|
||||||
if art == "Backdrop":
|
if art == "Backdrop":
|
||||||
try: # Backdrop is a list, grab the first backdrop
|
try:
|
||||||
|
# Backdrop is a list, grab the first backdrop
|
||||||
self.setArtProp(listItem, arttype, allartwork[art][0])
|
self.setArtProp(listItem, arttype, allartwork[art][0])
|
||||||
except: pass
|
except:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
self.setArtProp(listItem, arttype, allartwork[art])
|
self.setArtProp(listItem, arttype, allartwork[art])
|
||||||
|
|
||||||
def setArtProp(self, listItem, arttype, path):
|
def setArtProp(self, listItem, arttype, path):
|
||||||
|
|
||||||
if arttype in (
|
if arttype in (
|
||||||
'thumb', 'fanart_image', 'small_poster', 'tiny_poster',
|
'thumb', 'fanart_image', 'small_poster', 'tiny_poster',
|
||||||
'medium_landscape', 'medium_poster', 'small_fanartimage',
|
'medium_landscape', 'medium_poster', 'small_fanartimage',
|
||||||
'medium_fanartimage', 'fanart_noindicators'):
|
'medium_fanartimage', 'fanart_noindicators'):
|
||||||
|
|
||||||
listItem.setProperty(arttype, path)
|
listItem.setProperty(arttype, path)
|
||||||
else:
|
else:
|
||||||
listItem.setArt({arttype: path})
|
listItem.setArt({arttype: path})
|
||||||
|
|
Loading…
Reference in a new issue