Extend the artwork method

To grab parent artwork
This commit is contained in:
angelblue05 2015-10-13 10:40:21 -05:00
parent e2842d1b01
commit 46d8c1d4c2
2 changed files with 31 additions and 5 deletions

View file

@ -375,7 +375,7 @@ class API():
return mpaa return mpaa
def getAllArtwork(self, item): def getAllArtwork(self, item, parentInfo = False):
""" """
Get all artwork, it will return an empty string Get all artwork, it will return an empty string
@ -423,6 +423,33 @@ class API():
artwork = "%s/mediabrowser/Items/%s/Images/%s/0?MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" % (server, id, art, maxWidth, maxHeight, tag, quality) artwork = "%s/mediabrowser/Items/%s/Images/%s/0?MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" % (server, id, art, maxWidth, maxHeight, tag, quality)
allartworks[art] = artwork allartworks[art] = artwork
# Process parent items if the main item is missing artwork
if parentInfo:
# Process backdrops
if not allartworks['Backdrop']:
parentId = item.get('ParentBackdropItemId')
if parentId:
# If there is a parentId, go through the parent backdrop list
parentbackdrops = item['ParentBackdropImageTags']
backdropIndex = 0
for parentbackdroptag in parentbackdrops:
artwork = "%s/mediabrowser/Items/%s/Images/Backdrop/%s?MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" % (server, parentId, backdropIndex, maxWidth, maxHeight, parentbackdroptag, quality)
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%sItemId' % parentart]
artwork = "%s/mediabrowser/Items/%s/Images/%s/0?MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" % (server, parentId, parentart, maxWidth, maxHeight, parentTag, quality)
allartworks[parentart] = artwork
return allartworks return allartworks
def getArtwork(self, data, type, mediaType = "", index = "0", userParentInfo = False): def getArtwork(self, data, type, mediaType = "", index = "0", userParentInfo = False):

View file

@ -64,7 +64,7 @@ class WriteKodiMusicDB():
bio = API().getOverview(MBitem) bio = API().getOverview(MBitem)
# Associate artwork # Associate artwork
artworks = API().getAllArtwork(MBitem) artworks = API().getAllArtwork(MBitem, parentInfo=True)
thumb = artworks['Primary'] thumb = artworks['Primary']
backdrops = artworks['Backdrop'] # List backdrops = artworks['Backdrop'] # List
@ -162,7 +162,7 @@ class WriteKodiMusicDB():
artists = " / ".join(MBartists) artists = " / ".join(MBartists)
# Associate the artwork # Associate the artwork
artworks = API().getAllArtwork(MBitem) artworks = API().getAllArtwork(MBitem, parentInfo=True)
thumb = artworks['Primary'] thumb = artworks['Primary']
if thumb: if thumb:
thumb = "<thumb>%s</thumb>" % thumb thumb = "<thumb>%s</thumb>" % thumb
@ -222,7 +222,6 @@ class WriteKodiMusicDB():
# Update artwork # Update artwork
self.textureCache.addArtwork(artworks, albumid, "album", cursor) self.textureCache.addArtwork(artworks, albumid, "album", cursor)
self.textureCache.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), albumid, "album", "fanart", cursor)
# Link album to artists # Link album to artists
if MBartists: if MBartists:
@ -381,7 +380,7 @@ class WriteKodiMusicDB():
cursor.execute(query, (artistid, songid, artist['Name'])) cursor.execute(query, (artistid, songid, artist['Name']))
# Update artwork # Update artwork
self.textureCache.addArtwork(API().getAllArtwork(MBitem), songid, "song", cursor) self.textureCache.addArtwork(API().getAllArtwork(MBitem, parentInfo=True), songid, "song", cursor)
def deleteItemFromKodiLibrary(self, id, connection, cursor): def deleteItemFromKodiLibrary(self, id, connection, cursor):