Fixes to getExtraFanart. If not using PKC repository, you will have to manually update plugin.video.plexkodiconnect.movies and plugin.video.plexkodiconnect.tvshows. Fixes #62
This commit is contained in:
parent
133741b567
commit
70ade15e8d
1 changed files with 56 additions and 58 deletions
|
@ -1282,68 +1282,66 @@ def getVideoFiles(plexId, params):
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
##### GET EXTRAFANART FOR LISTITEM #####
|
def getExtraFanArt(plexid, plexPath):
|
||||||
def getExtraFanArt(plexid,embyPath):
|
"""
|
||||||
|
Get extrafanart for listitem
|
||||||
|
will be called by skinhelper script to get the extrafanart
|
||||||
|
for tvshows we get the plexid just from the path
|
||||||
|
"""
|
||||||
|
utils.logMsg(title, 'getExtraFanArt called with plexid: %s, plexPath: %s'
|
||||||
|
% (plexid, plexPath), 1)
|
||||||
|
if not plexid:
|
||||||
|
if "plugin.video.plexkodiconnect" in plexPath:
|
||||||
|
plexid = plexPath.split("/")[-2]
|
||||||
|
if not plexid:
|
||||||
|
utils.logMsg(title, 'Could not get a plexid, aborting', -1)
|
||||||
|
return xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
emby = embyserver.Read_EmbyServer()
|
|
||||||
art = artwork.Artwork()
|
|
||||||
|
|
||||||
# Get extrafanart for listitem
|
|
||||||
# will be called by skinhelper script to get the extrafanart
|
|
||||||
try:
|
try:
|
||||||
# for tvshows we get the plexid just from the path
|
# We need to store the images locally for this to work
|
||||||
if not plexid:
|
# because of the caching system in xbmc
|
||||||
if "plugin.video.emby" in embyPath:
|
fanartDir = utils.tryDecode(xbmc.translatePath(
|
||||||
plexid = embyPath.split("/")[-2]
|
"special://thumbnails/plex/%s/" % plexid))
|
||||||
|
if not xbmcvfs.exists(fanartDir):
|
||||||
|
# Download the images to the cache directory
|
||||||
|
xbmcvfs.mkdirs(utils.tryEncode(fanartDir))
|
||||||
|
xml = PlexFunctions.GetPlexMetadata(plexid)
|
||||||
|
if xml is None:
|
||||||
|
utils.logMsg('Could not download metadata for %s' % plexid, -1)
|
||||||
|
return xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
if plexid:
|
API = PlexAPI.API(xml[0])
|
||||||
#only proceed if we actually have a emby id
|
backdrops = API.getAllArtwork()['Backdrop']
|
||||||
utils.logMsg("EMBY", "Requesting extrafanart for Id: %s" % plexid, 0)
|
for count, backdrop in enumerate(backdrops):
|
||||||
|
# Same ordering as in artwork
|
||||||
# We need to store the images locally for this to work
|
if os.path.supports_unicode_filenames:
|
||||||
# because of the caching system in xbmc
|
fanartFile = os.path.join(fanartDir,
|
||||||
fanartDir = utils.tryDecode(xbmc.translatePath(
|
"fanart%.3d.jpg" % count)
|
||||||
"special://thumbnails/emby/%s/" % plexid))
|
else:
|
||||||
|
fanartFile = os.path.join(
|
||||||
if not xbmcvfs.exists(fanartDir):
|
utils.tryEncode(fanartDir),
|
||||||
# Download the images to the cache directory
|
utils.tryEncode("fanart%.3d.jpg" % count))
|
||||||
xbmcvfs.mkdirs(fanartDir)
|
li = xbmcgui.ListItem("%.3d" % count, path=fanartFile)
|
||||||
item = emby.getItem(plexid)
|
xbmcplugin.addDirectoryItem(
|
||||||
if item:
|
handle=int(sys.argv[1]),
|
||||||
backdrops = art.getAllArtwork(item)['Backdrop']
|
url=fanartFile,
|
||||||
tags = item['BackdropImageTags']
|
listitem=li)
|
||||||
count = 0
|
xbmcvfs.copy(backdrop, fanartFile)
|
||||||
for backdrop in backdrops:
|
else:
|
||||||
# Same ordering as in artwork
|
utils.logMsg(title, "Found cached backdrop.", 1)
|
||||||
tag = tags[count]
|
# Use existing cached images
|
||||||
if os.path.supports_unicode_filenames:
|
dirs, files = xbmcvfs.listdir(fanartDir)
|
||||||
fanartFile = os.path.join(fanartDir, "fanart%s.jpg" % tag)
|
for file in files:
|
||||||
else:
|
fanartFile = os.path.join(fanartDir, utils.tryDecode(file))
|
||||||
fanartFile = os.path.join(
|
li = xbmcgui.ListItem(file, path=fanartFile)
|
||||||
utils.tryEncode(fanartDir),
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
|
||||||
"fanart%s.jpg" % utils.tryEncode(tag))
|
|
||||||
li = xbmcgui.ListItem(tag, path=fanartFile)
|
|
||||||
xbmcplugin.addDirectoryItem(
|
|
||||||
handle=int(sys.argv[1]),
|
|
||||||
url=fanartFile,
|
|
||||||
listitem=li)
|
|
||||||
xbmcvfs.copy(backdrop, fanartFile)
|
|
||||||
count += 1
|
|
||||||
else:
|
|
||||||
utils.logMsg("EMBY", "Found cached backdrop.", 2)
|
|
||||||
# Use existing cached images
|
|
||||||
dirs, files = xbmcvfs.listdir(fanartDir)
|
|
||||||
for file in files:
|
|
||||||
fanartFile = os.path.join(fanartDir, utils.tryDecode(file))
|
|
||||||
li = xbmcgui.ListItem(file, path=fanartFile)
|
|
||||||
xbmcplugin.addDirectoryItem(
|
|
||||||
handle=int(sys.argv[1]),
|
|
||||||
url=fanartFile,
|
url=fanartFile,
|
||||||
listitem=li)
|
listitem=li)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
utils.logMsg("EMBY", "Error getting extrafanart: %s" % e, 0)
|
utils.logMsg(title, "Error getting extrafanart: %s" % e, -1)
|
||||||
|
import traceback
|
||||||
# Always do endofdirectory to prevent errors in the logs
|
utils.logMsg("Traceback:\n%s" % traceback.format_exc(), 0)
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue