From 46d8c1d4c2cf1008d36ac0cfaaab9101a6aa1a49 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 13 Oct 2015 10:40:21 -0500 Subject: [PATCH] Extend the artwork method To grab parent artwork --- resources/lib/API.py | 29 ++++++++++++++++++++++++++++- resources/lib/WriteKodiMusicDB.py | 7 +++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/resources/lib/API.py b/resources/lib/API.py index 2778728d..6b8d0bfa 100644 --- a/resources/lib/API.py +++ b/resources/lib/API.py @@ -375,7 +375,7 @@ class API(): return mpaa - def getAllArtwork(self, item): + def getAllArtwork(self, item, parentInfo = False): """ 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) 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 def getArtwork(self, data, type, mediaType = "", index = "0", userParentInfo = False): diff --git a/resources/lib/WriteKodiMusicDB.py b/resources/lib/WriteKodiMusicDB.py index 44a12c49..2d98b34f 100644 --- a/resources/lib/WriteKodiMusicDB.py +++ b/resources/lib/WriteKodiMusicDB.py @@ -64,7 +64,7 @@ class WriteKodiMusicDB(): bio = API().getOverview(MBitem) # Associate artwork - artworks = API().getAllArtwork(MBitem) + artworks = API().getAllArtwork(MBitem, parentInfo=True) thumb = artworks['Primary'] backdrops = artworks['Backdrop'] # List @@ -162,7 +162,7 @@ class WriteKodiMusicDB(): artists = " / ".join(MBartists) # Associate the artwork - artworks = API().getAllArtwork(MBitem) + artworks = API().getAllArtwork(MBitem, parentInfo=True) thumb = artworks['Primary'] if thumb: thumb = "%s" % thumb @@ -222,7 +222,6 @@ class WriteKodiMusicDB(): # Update artwork self.textureCache.addArtwork(artworks, albumid, "album", cursor) - self.textureCache.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), albumid, "album", "fanart", cursor) # Link album to artists if MBartists: @@ -381,7 +380,7 @@ class WriteKodiMusicDB(): cursor.execute(query, (artistid, songid, artist['Name'])) # 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):