Fix tv show season posters not showing

This commit is contained in:
tomkat83 2016-03-13 16:06:54 +01:00
parent 53c07d4b50
commit d300cc60d6
3 changed files with 41 additions and 54 deletions

View file

@ -2044,15 +2044,15 @@ class API():
""" """
item = self.item.attrib item = self.item.attrib
maxHeight = 10000 # maxHeight = 10000
maxWidth = 10000 # maxWidth = 10000
customquery = "" # customquery = ""
if utils.settings('compressArt') == "true": # if utils.settings('compressArt') == "true":
customquery = "&Quality=90" # customquery = "&Quality=90"
if utils.settings('enableCoverArt') == "false": # if utils.settings('enableCoverArt') == "false":
customquery += "&EnableImageEnhancers=false" # customquery += "&EnableImageEnhancers=false"
allartworks = { allartworks = {
'Primary': "", 'Primary': "",
@ -2083,54 +2083,21 @@ class API():
# 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')
parentId = item.get('ParentBackdropItemId') if background:
if parentId: background = "%s%s" % (self.server, background)
# If there is a parentId, go through the parent backdrop list background = self.addPlexCredentialsToUrl(background)
parentbackdrops = item['ParentBackdropImageTags'] allartworks['Backdrop'].append(background)
backdropIndex = 0
for parentbackdroptag in parentbackdrops:
artwork = (
"%s/emby/Items/%s/Images/Backdrop/%s?"
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
% (self.server, parentId, backdropIndex,
maxWidth, maxHeight, parentbackdroptag, customquery))
allartworks['Backdrop'].append(artwork)
backdropIndex += 1
# Process the rest of the artwork
parentartwork = ['Logo', 'Art', 'Thumb']
for parentart in parentartwork:
if not allartworks[parentart]:
parentId = item.get('Parent%sItemId' % parentart)
if parentId:
parentTag = item['Parent%sImageTag' % parentart]
artwork = (
"%s/emby/Items/%s/Images/%s/0?"
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
% (self.server, parentId, parentart,
maxWidth, maxHeight, parentTag, customquery))
allartworks[parentart] = artwork
# Parent album works a bit differently
if not allartworks['Primary']: if not allartworks['Primary']:
primary = item['parentThumb']
if primary:
primary = "%s%s" % (self.server, primary)
primary = self.addPlexCredentialsToUrl(primary)
allartworks['Primary'] = primary
parentId = item.get('AlbumId')
if parentId and item.get('AlbumPrimaryImageTag'):
parentTag = item['AlbumPrimaryImageTag']
artwork = (
"%s/emby/Items/%s/Images/Primary/0?"
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
% (self.server, parentId, maxWidth, maxHeight, parentTag, customquery))
allartworks['Primary'] = artwork
return allartworks return allartworks
def getTranscodeVideoPath(self, action, quality={}): def getTranscodeVideoPath(self, action, quality={}):

View file

@ -1141,9 +1141,8 @@ class TVShows(Items):
# skip this item for now # skip this item for now
return return
def run_add_updateSeason(self, item, viewid=None, viewtag=None): def run_add_updateSeason(self, item, viewtag=None, viewid=None):
API = PlexAPI.API(item) API = PlexAPI.API(item)
showid = viewid
itemid = API.getRatingKey() itemid = API.getRatingKey()
if not itemid: if not itemid:
self.logMsg('Error getting itemid for season, skipping', -1) self.logMsg('Error getting itemid for season, skipping', -1)
@ -1153,6 +1152,18 @@ class TVShows(Items):
kodi_db = self.kodi_db kodi_db = self.kodi_db
artwork = self.artwork artwork = self.artwork
seasonnum = API.getIndex() seasonnum = API.getIndex()
# Get parent tv show Plex id
plexshowid = item.attrib.get('parentRatingKey')
# Get Kodi showid
emby_dbitem = emby_db.getItem_byId(plexshowid)
try:
showid = emby_dbitem[0]
except:
self.logMsg('Could not find parent tv show for season %s. '
'Skipping season for now.'
% (itemid), -1)
return
seasonid = kodi_db.addSeason(showid, seasonnum) seasonid = kodi_db.addSeason(showid, seasonnum)
checksum = API.getChecksum() checksum = API.getChecksum()
# Check whether Season already exists # Check whether Season already exists
@ -1165,6 +1176,7 @@ class TVShows(Items):
# Process artwork # Process artwork
allartworks = API.getAllArtwork() allartworks = API.getAllArtwork()
self.logMsg('TV id: %s, Seasonid: %s' % (viewid, seasonid), 1)
artwork.addArtwork(allartworks, seasonid, "season", kodicursor) artwork.addArtwork(allartworks, seasonid, "season", kodicursor)
if update_item: if update_item:
@ -1172,7 +1184,7 @@ class TVShows(Items):
emby_db.updateReference(itemid, checksum) emby_db.updateReference(itemid, checksum)
else: else:
# Create the reference in emby table # Create the reference in emby table
emby_db.addReference(itemid, seasonid, "Season", "season", parentid=showid, checksum=checksum) emby_db.addReference(itemid, seasonid, "Season", "season", parentid=viewid, checksum=checksum)
def add_updateEpisode(self, item, viewtag=None, viewid=None): def add_updateEpisode(self, item, viewtag=None, viewid=None):
try: try:

View file

@ -1218,6 +1218,10 @@ class LibrarySync(Thread):
# COPY for later use # COPY for later use
allPlexTvShowsId = self.allPlexElementsId.copy() allPlexTvShowsId = self.allPlexElementsId.copy()
# Process self.updatelist
self.GetAndProcessXMLs(itemType)
self.logMsg("GetAndProcessXMLs completed for tv shows", 1)
# PROCESS TV Seasons ##### # PROCESS TV Seasons #####
# Cycle through tv shows # Cycle through tv shows
for tvShowId in allPlexTvShowsId: for tvShowId in allPlexTvShowsId:
@ -1238,6 +1242,10 @@ class LibrarySync(Thread):
self.logMsg("Analyzed all seasons of TV show with Plex Id %s" self.logMsg("Analyzed all seasons of TV show with Plex Id %s"
% tvShowId, 1) % tvShowId, 1)
# Process self.updatelist
self.GetAndProcessXMLs(itemType)
self.logMsg("GetAndProcessXMLs completed for seasons", 1)
# PROCESS TV Episodes ##### # PROCESS TV Episodes #####
# Cycle through tv shows # Cycle through tv shows
for view in views: for view in views:
@ -1261,7 +1269,7 @@ class LibrarySync(Thread):
# Process self.updatelist # Process self.updatelist
self.GetAndProcessXMLs(itemType) self.GetAndProcessXMLs(itemType)
self.logMsg("GetAndProcessXMLs completed", 1) self.logMsg("GetAndProcessXMLs completed for episodes", 1)
# Refresh season info # Refresh season info
# Cycle through tv shows # Cycle through tv shows
with itemtypes.TVShows() as TVshow: with itemtypes.TVShows() as TVshow: