From 4e802623c3aea66297dacb09c09d46923f406004 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 29 Jun 2015 11:44:55 -0500 Subject: [PATCH] Revert "Revert "First attempt at supporting cover art"" This reverts commit fadc3e0e4983f79aebda5ce5cc15b944c43d1948. --- resources/lib/API.py | 18 +++++-- resources/lib/WriteKodiVideoDB.py | 88 +++++++++++++++---------------- resources/settings.xml | 1 + 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/resources/lib/API.py b/resources/lib/API.py index 03e3b0f1..9f5bf878 100644 --- a/resources/lib/API.py +++ b/resources/lib/API.py @@ -316,7 +316,7 @@ class API(): tempDate = "01.01.2000" return tempDate - def getArtwork(self, data, type, index = "0", userParentInfo = False): + def getArtwork(self, data, type, mediaType, index = "0", userParentInfo = False): addonSettings = xbmcaddon.Addon(id='plugin.video.emby') id = data.get("Id") @@ -371,11 +371,21 @@ class API(): id = data.get("ParentBackdropItemId") query = "" - height = "10000" - width = "10000" + maxHeight = "10000" + maxWidth = "10000" + height = "" + width = "" played = "0" totalbackdrops = 0 + if addonSettings.getSetting('coverArtratio') == "true": + if mediaType in ("movie","boxset","tvshow"): + if "Primary" in type: + # Only force ratio for cover art for main covers + aspectratio = data.get("PrimaryImageAspectRatio") + width = "&Width=1000" + height = "&Height=1480" + if originalType =="BackdropNoIndicators" and index == "0" and data.get("BackdropImageTags") != None: totalbackdrops = len(data.get("BackdropImageTags")) if totalbackdrops != 0: @@ -392,7 +402,7 @@ class API(): if imageTag == None: imageTag = "e3ab56fe27d389446754d0fb04910a34" - artwork = "%s/mediabrowser/Items/%s/Images/%s/%s?MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" % (server, id, type, index, width, height, imageTag, query) + artwork = "%s/mediabrowser/Items/%s/Images/%s/%s?MaxWidth=%s&MaxHeight=%s%s%s&Format=original&Tag=%s%s" % (server, id, type, index, maxWidth, maxHeight, height, width, imageTag, query) #artwork = "%s/mediabrowser/Items/%s/Images/%s/%s/%s/original/%s/%s/%s?%s" % (server, id, type, index, imageTag, width, height, played, query) <- broken if addonSettings.getSetting('disableCoverArt')=='true': artwork = artwork + "&EnableImageEnhancers=false" diff --git a/resources/lib/WriteKodiVideoDB.py b/resources/lib/WriteKodiVideoDB.py index 5de8f6b6..239aa0d2 100644 --- a/resources/lib/WriteKodiVideoDB.py +++ b/resources/lib/WriteKodiVideoDB.py @@ -218,14 +218,14 @@ class WriteKodiVideoDB(): self.AddPeopleToMedia(movieid,MBitem.get("People"),"movie", connection, cursor) #update artwork - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), movieid, "movie", "thumb", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), movieid, "movie", "poster", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), movieid, "movie", "banner", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), movieid, "movie", "clearlogo", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), movieid, "movie", "clearart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), movieid, "movie", "landscape", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), movieid, "movie", "discart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), movieid, "movie", "fanart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "movie"), movieid, "movie", "thumb", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "movie"), movieid, "movie", "poster", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Banner", mediaType = "movie"), movieid, "movie", "banner", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Logo", mediaType = "movie"), movieid, "movie", "clearlogo", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Art", mediaType = "movie"), movieid, "movie", "clearart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb", mediaType = "movie"), movieid, "movie", "landscape", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Disc", mediaType = "movie"), movieid, "movie", "discart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop", mediaType = "movie"), movieid, "movie", "fanart", cursor) #update genres self.AddGenresToMedia(movieid, genres, "movie", cursor) @@ -379,14 +379,14 @@ class WriteKodiVideoDB(): self.AddPeopleToMedia(idMVideo,MBitem.get("People"),"musicvideo", connection, cursor) #update artwork - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), idMVideo, "musicvideo", "thumb", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), idMVideo, "musicvideo", "poster", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), idMVideo, "musicvideo", "banner", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), idMVideo, "musicvideo", "clearlogo", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), idMVideo, "musicvideo", "clearart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), idMVideo, "musicvideo", "landscape", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), idMVideo, "musicvideo", "discart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), idMVideo, "musicvideo", "fanart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "musicvideo"), idMVideo, "musicvideo", "thumb", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "musicvideo"), idMVideo, "musicvideo", "poster", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Banner", mediaType = "musicvideo"), idMVideo, "musicvideo", "banner", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Logo", mediaType = "musicvideo"), idMVideo, "musicvideo", "clearlogo", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Art", mediaType = "musicvideo"), idMVideo, "musicvideo", "clearart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb", mediaType = "musicvideo"), idMVideo, "musicvideo", "landscape", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Disc", mediaType = "musicvideo"), idMVideo, "musicvideo", "discart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop", mediaType = "musicvideo"), idMVideo, "musicvideo", "fanart", cursor) #update genres self.AddGenresToMedia(idMVideo, genres, "musicvideo", cursor) @@ -418,7 +418,7 @@ class WriteKodiVideoDB(): timeInfo = API().getTimeInfo(MBitem) userData=API().getUserData(MBitem) - thumbPath = API().getArtwork(MBitem, "Primary") + #thumbPath = API().getArtwork(MBitem, "Primary") # If the item already exist in the local Kodi DB we'll perform a full item update # If the item doesn't exist, we'll add it to the database @@ -540,14 +540,14 @@ class WriteKodiVideoDB(): self.AddTagToMedia(showid, "Favorite tvshows", "tvshow", cursor, True) #update artwork - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), showid, "tvshow", "thumb", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), showid, "tvshow", "poster", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), showid, "tvshow", "banner", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), showid, "tvshow", "clearlogo", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), showid, "tvshow", "clearart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), showid, "tvshow", "landscape", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), showid, "tvshow", "discart", cursor) - self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), showid, "tvshow", "fanart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "tvshow"), showid, "tvshow", "thumb", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "tvshow"), showid, "tvshow", "poster", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Banner", mediaType = "tvshow"), showid, "tvshow", "banner", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Logo", mediaType = "tvshow"), showid, "tvshow", "clearlogo", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Art", mediaType = "tvshow"), showid, "tvshow", "clearart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb", mediaType = "tvshow"), showid, "tvshow", "landscape", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Disc", mediaType = "tvshow"), showid, "tvshow", "discart", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop", mediaType = "tvshow"), showid, "tvshow", "fanart", cursor) #update season details self.updateSeasons(MBitem["Id"], showid, connection, cursor) @@ -705,7 +705,7 @@ class WriteKodiVideoDB(): self.AddStreamDetailsToMedia(API().getMediaStreams(MBitem), fileid, cursor) #update artwork - self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), episodeid, "episode", "thumb", cursor) + self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "episode"), episodeid, "episode", "thumb", cursor) def deleteItemFromKodiLibrary(self, id, connection, cursor ): @@ -749,13 +749,13 @@ class WriteKodiVideoDB(): seasonid = result[0] #update artwork - imageUrl = API().getArtwork(season, "Thumb") + imageUrl = API().getArtwork(season, "Thumb", mediaType = "season") self.addOrUpdateArt(imageUrl, seasonid, "season", "landscape", cursor) - imageUrl = API().getArtwork(season, "Primary") + imageUrl = API().getArtwork(season, "Primary", mediaType = "season") self.addOrUpdateArt(imageUrl, seasonid, "season", "poster", cursor) - imageUrl = API().getArtwork(season, "Banner") + imageUrl = API().getArtwork(season, "Banner", mediaType = "season") self.addOrUpdateArt(imageUrl, seasonid, "season", "banner", cursor) # Set All season poster MBitem = ReadEmbyDB().getFullItem(embyTvShowId) @@ -770,7 +770,7 @@ class WriteKodiVideoDB(): cursor.execute("INSERT into seasons(idSeason, idShow, season) values(?, ?, ?)", (seasonid, kodiTvShowId, seasonNum)) else: seasonid = result[0] - imageUrl = API().getArtwork(MBitem, "Primary") + imageUrl = API().getArtwork(MBitem, "Primary", mediaType = "season") self.addOrUpdateArt(imageUrl, seasonid, "season", "poster", cursor) def addOrUpdateArt(self, imageUrl, kodiId, mediaType, imageType, cursor): @@ -1147,13 +1147,13 @@ class WriteKodiVideoDB(): existing_type_map[row[0] ] = row[1] artwork = {} - artwork["poster"] = API().getArtwork(boxset, "Primary") - artwork["banner"] = API().getArtwork(boxset, "Banner") - artwork["clearlogo"] = API().getArtwork(boxset, "Logo") - artwork["clearart"] = API().getArtwork(boxset, "Art") - artwork["landscape"] = API().getArtwork(boxset, "Thumb") - artwork["discart"] = API().getArtwork(boxset, "Disc") - artwork["fanart"] = API().getArtwork(boxset, "Backdrop") + artwork["poster"] = API().getArtwork(boxset, "Primary", mediaType = "boxset") + artwork["banner"] = API().getArtwork(boxset, "Banner", mediaType = "boxset") + artwork["clearlogo"] = API().getArtwork(boxset, "Logo", mediaType = "boxset") + artwork["clearart"] = API().getArtwork(boxset, "Art", mediaType = "boxset") + artwork["landscape"] = API().getArtwork(boxset, "Thumb", mediaType = "boxset") + artwork["discart"] = API().getArtwork(boxset, "Disc", mediaType = "boxset") + artwork["fanart"] = API().getArtwork(boxset, "Backdrop", mediaType = "boxset") art_types = ['poster','fanart','landscape','clearlogo','clearart','banner','discart'] for update_type in art_types: @@ -1184,13 +1184,13 @@ class WriteKodiVideoDB(): existing_type_map[row[0] ] = row[1] artwork = {} - artwork["poster"] = API().getArtwork(boxset, "Primary") - artwork["banner"] = API().getArtwork(boxset, "Banner") - artwork["clearlogo"] = API().getArtwork(boxset, "Logo") - artwork["clearart"] = API().getArtwork(boxset, "Art") - artwork["landscape"] = API().getArtwork(boxset, "Thumb") - artwork["discart"] = API().getArtwork(boxset, "Disc") - artwork["fanart"] = API().getArtwork(boxset, "Backdrop") + artwork["poster"] = API().getArtwork(boxset, "Primary", mediaType = "boxset") + artwork["banner"] = API().getArtwork(boxset, "Banner", mediaType = "boxset") + artwork["clearlogo"] = API().getArtwork(boxset, "Logo", mediaType = "boxset") + artwork["clearart"] = API().getArtwork(boxset, "Art", mediaType = "boxset") + artwork["landscape"] = API().getArtwork(boxset, "Thumb", mediaType = "boxset") + artwork["discart"] = API().getArtwork(boxset, "Disc", mediaType = "boxset") + artwork["fanart"] = API().getArtwork(boxset, "Backdrop", mediaType = "boxset") art_types = ['poster','fanart','landscape','clearlogo','clearart','banner','discart'] for update_type in art_types: diff --git a/resources/settings.xml b/resources/settings.xml index fd9facd4..ca9ca221 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -31,6 +31,7 @@ +