mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
New artwork method implement
Old method still available for backward compatibility
This commit is contained in:
parent
6c4242abeb
commit
06ad9ab18c
3 changed files with 87 additions and 115 deletions
|
@ -137,18 +137,32 @@ class TextureCache():
|
||||||
for art in artwork:
|
for art in artwork:
|
||||||
|
|
||||||
if art == "Backdrop":
|
if art == "Backdrop":
|
||||||
# Backdrop entry is a list
|
# Backdrop entry is a list, process extra fanart for artwork downloader (fanart, fanart1, fanart2, etc.)
|
||||||
artList = artwork[art]
|
backdrops = artwork[art]
|
||||||
if artList:
|
backdropsNumber = len(backdrops)
|
||||||
self.addOrUpdateArt(artList[0], kodiId, mediaType, kodiart[art], cursor)
|
|
||||||
|
cursor.execute("SELECT url FROM art WHERE media_id = ? AND media_type = ? AND type LIKE ?", (kodiId, mediaType, "fanart%",))
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
|
if len(rows) > backdropsNumber:
|
||||||
|
# More backdrops in database than what we are going to process. Delete extra fanart.
|
||||||
|
cursor.execute("DELETE FROM art WHERE media_id = ? AND media_type = ? AND type LIKE ?", (kodiId, mediaType, "fanart_",))
|
||||||
|
|
||||||
|
index = ""
|
||||||
|
for backdrop in backdrops:
|
||||||
|
self.addOrUpdateArt(backdrop, kodiId, mediaType, "%s%s" % ("fanart", index), cursor)
|
||||||
|
if backdropsNumber > 1:
|
||||||
|
try: # Will only fail on the first try, str to int.
|
||||||
|
index += 1
|
||||||
|
except TypeError:
|
||||||
|
index = 1
|
||||||
|
|
||||||
elif art == "Primary":
|
elif art == "Primary":
|
||||||
# Primary art is processed as thumb and poster for Kodi.
|
# Primary art is processed as thumb and poster for Kodi.
|
||||||
for artType in kodiart[art]:
|
for artType in kodiart[art]:
|
||||||
self.addOrUpdateArt(artwork[art], kodiId, mediaType, artType, cursor)
|
self.addOrUpdateArt(artwork[art], kodiId, mediaType, artType, cursor)
|
||||||
|
|
||||||
else:
|
else: # For banner, logo, art, thumb, disc
|
||||||
# For banner, logo, art, thumb, disc
|
|
||||||
self.addOrUpdateArt(artwork[art], kodiId, mediaType, kodiart[art], cursor)
|
self.addOrUpdateArt(artwork[art], kodiId, mediaType, kodiart[art], cursor)
|
||||||
|
|
||||||
def addOrUpdateArt(self, imageUrl, kodiId, mediaType, imageType, cursor):
|
def addOrUpdateArt(self, imageUrl, kodiId, mediaType, imageType, cursor):
|
||||||
|
@ -166,14 +180,14 @@ class TextureCache():
|
||||||
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
query = "INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
cursor.execute(query, (kodiId, mediaType, imageType, imageUrl))
|
||||||
|
|
||||||
else:
|
else: # Only cache artwork if it changed
|
||||||
if url != imageUrl:
|
if url != imageUrl:
|
||||||
cacheimage = True
|
cacheimage = True
|
||||||
|
|
||||||
# Only for backdrop
|
# Only for the main backdrop, poster
|
||||||
if imageType == "fanart":
|
if imageType in {"fanart", "poster"}:
|
||||||
# Delete current entry before updating with the new one
|
# Delete current entry before updating with the new one
|
||||||
self.deleteFanart(url)
|
self.deleteCachedArtwork(url)
|
||||||
|
|
||||||
self.logMsg("Updating Art Link for kodiId: %s (%s) -> (%s)" % (kodiId, url, imageUrl), 1)
|
self.logMsg("Updating Art Link for kodiId: %s (%s) -> (%s)" % (kodiId, url, imageUrl), 1)
|
||||||
query = "UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?"
|
query = "UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?"
|
||||||
|
@ -188,26 +202,31 @@ class TextureCache():
|
||||||
if url and self.enableTextureCache:
|
if url and self.enableTextureCache:
|
||||||
self.logMsg("Processing: %s" % url, 2)
|
self.logMsg("Processing: %s" % url, 2)
|
||||||
|
|
||||||
# add image to texture cache by simply calling it at the http endpoint
|
# Add image to texture cache by simply calling it at the http endpoint
|
||||||
url = self.double_urlencode(url)
|
url = self.double_urlencode(url)
|
||||||
try:
|
try: # Extreme short timeouts so we will have a exception, but we don't need the result so pass
|
||||||
response = requests.head('http://%s:%s/image/image://%s' % (self.xbmc_host, self.xbmc_port, url), auth=(self.xbmc_username, self.xbmc_password),timeout=(0.01, 0.01))
|
response = requests.head('http://%s:%s/image/image://%s' % (self.xbmc_host, self.xbmc_port, url), auth=(self.xbmc_username, self.xbmc_password), timeout=(0.01, 0.01))
|
||||||
except:
|
except: pass
|
||||||
#extreme short timeouts so we will have a exception, but we don't need the result so pass
|
|
||||||
pass
|
|
||||||
|
|
||||||
def deleteFanart(self, url):
|
def deleteCachedArtwork(self, url):
|
||||||
# Only necessary to remove and apply a new backdrop
|
# Only necessary to remove and apply a new backdrop or poster
|
||||||
connection = utils.KodiSQL('texture')
|
connection = utils.KodiSQL('texture')
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
cursor.execute("SELECT cachedurl FROM texture WHERE url = ?", (url,))
|
cursor.execute("SELECT cachedurl FROM texture WHERE url = ?", (url,))
|
||||||
try:
|
try:
|
||||||
cursor.fetchone()[0]
|
cachedurl = cursor.fetchone()[0]
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.logMsg("Could not find cached url.", 1)
|
self.logMsg("Could not find cached url.", 1)
|
||||||
else:
|
|
||||||
|
else: # Delete thumbnail as well as the entry
|
||||||
|
thumbnails = xbmc.translatePath("special://thumbnails/%s" % cachedurl)
|
||||||
|
self.logMsg("Deleting cached thumbnail: %s" % thumbnails, 1)
|
||||||
|
xbmcvfs.delete(thumbnails)
|
||||||
|
|
||||||
cursor.execute("DELETE FROM texture WHERE url = ?", (url,))
|
cursor.execute("DELETE FROM texture WHERE url = ?", (url,))
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
cursor.close()
|
cursor.close()
|
|
@ -64,12 +64,16 @@ class WriteKodiMusicDB():
|
||||||
bio = API().getOverview(MBitem)
|
bio = API().getOverview(MBitem)
|
||||||
|
|
||||||
# Associate artwork
|
# Associate artwork
|
||||||
thumb = API().getArtwork(MBitem, "Primary")
|
artworks = API().getAllArtwork(MBitem)
|
||||||
|
thumb = artworks['Primary']
|
||||||
|
backdrops = artworks['Backdrop'] # List
|
||||||
|
|
||||||
if thumb:
|
if thumb:
|
||||||
thumb = "<thumb>%s</thumb>" % thumb
|
thumb = "<thumb>%s</thumb>" % thumb
|
||||||
fanart = API().getArtwork(MBitem, "Backdrop")
|
if backdrops:
|
||||||
if fanart:
|
fanart = "<fanart>%s</fanart>" % backdrops[0]
|
||||||
fanart = "<fanart>%s</fanart>" % fanart
|
else:
|
||||||
|
fanart = ""
|
||||||
|
|
||||||
##### UPDATE THE ARTIST #####
|
##### UPDATE THE ARTIST #####
|
||||||
if artistid:
|
if artistid:
|
||||||
|
@ -121,16 +125,8 @@ class WriteKodiMusicDB():
|
||||||
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)"
|
query = "INSERT INTO emby(emby_id, kodi_id, media_type, checksum) values(?, ?, ?, ?)"
|
||||||
cursor.execute(query, (embyId, artistid, "artist", checksum))
|
cursor.execute(query, (embyId, artistid, "artist", checksum))
|
||||||
|
|
||||||
|
|
||||||
# Update artwork
|
# Update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), artistid, "artist", "thumb", cursor)
|
self.textureCache.addArtwork(artworks, artistid, "artist", cursor)
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), artistid, "artist", "poster", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), artistid, "artist", "banner", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), artistid, "artist", "clearlogo", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), artistid, "artist", "clearart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), artistid, "artist", "landscape", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), artistid, "artist", "discart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), artistid, "artist", "fanart", cursor)
|
|
||||||
|
|
||||||
def addOrUpdateAlbumToKodiLibrary(self, MBitem, connection, cursor):
|
def addOrUpdateAlbumToKodiLibrary(self, MBitem, connection, cursor):
|
||||||
|
|
||||||
|
@ -166,7 +162,8 @@ class WriteKodiMusicDB():
|
||||||
artists = " / ".join(MBartists)
|
artists = " / ".join(MBartists)
|
||||||
|
|
||||||
# Associate the artwork
|
# Associate the artwork
|
||||||
thumb = API().getArtwork(MBitem, "Primary")
|
artworks = API().getAllArtwork(MBitem)
|
||||||
|
thumb = artworks['Primary']
|
||||||
if thumb:
|
if thumb:
|
||||||
thumb = "<thumb>%s</thumb>" % thumb
|
thumb = "<thumb>%s</thumb>" % thumb
|
||||||
|
|
||||||
|
@ -224,14 +221,7 @@ class WriteKodiMusicDB():
|
||||||
self.AddGenresToMedia(albumid, genres, "album", cursor)
|
self.AddGenresToMedia(albumid, genres, "album", cursor)
|
||||||
|
|
||||||
# Update artwork
|
# Update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), albumid, "album", "thumb", cursor)
|
self.textureCache.addArtwork(artworks, albumid, "album", cursor)
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "BoxRear"), albumid, "album", "poster", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), albumid, "album", "banner", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), albumid, "album", "clearlogo", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), albumid, "album", "clearart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), albumid, "album", "landscape", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), albumid, "album", "discart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), albumid, "album", "fanart", cursor)
|
|
||||||
|
|
||||||
# Link album to artists
|
# Link album to artists
|
||||||
if MBartists:
|
if MBartists:
|
||||||
|
@ -390,14 +380,7 @@ class WriteKodiMusicDB():
|
||||||
cursor.execute(query, (artistid, songid, artist['Name']))
|
cursor.execute(query, (artistid, songid, artist['Name']))
|
||||||
|
|
||||||
# Update artwork
|
# Update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), songid, "song", "thumb", cursor)
|
self.textureCache.addArtwork(API().getAllArtwork(MBitem), songid, "song", cursor)
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary"), songid, "song", "poster", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Banner"), songid, "song", "banner", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Logo"), songid, "song", "clearlogo", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Art"), songid, "song", "clearart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Thumb"), songid, "song", "landscape", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), songid, "song", "discart", cursor)
|
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), songid, "song", "fanart", cursor)
|
|
||||||
|
|
||||||
def deleteItemFromKodiLibrary(self, id, connection, cursor):
|
def deleteItemFromKodiLibrary(self, id, connection, cursor):
|
||||||
|
|
||||||
|
|
|
@ -234,19 +234,12 @@ class WriteKodiVideoDB():
|
||||||
|
|
||||||
self.AddTagsToMedia(movieid, tags, "movie", cursor)
|
self.AddTagsToMedia(movieid, tags, "movie", cursor)
|
||||||
|
|
||||||
|
# Update artwork
|
||||||
|
self.textureCache.addArtwork(API().getAllArtwork(MBitem), movieid, "movie", cursor)
|
||||||
|
|
||||||
# Update or insert actors
|
# Update or insert actors
|
||||||
self.AddPeopleToMedia(movieid, MBitem.get('People'), "movie", connection, cursor)
|
self.AddPeopleToMedia(movieid, MBitem.get('People'), "movie", connection, cursor)
|
||||||
|
|
||||||
# Update artwork
|
|
||||||
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
|
# Update genres
|
||||||
self.AddGenresToMedia(movieid, genres, "movie", cursor)
|
self.AddGenresToMedia(movieid, genres, "movie", cursor)
|
||||||
|
|
||||||
|
@ -405,18 +398,12 @@ class WriteKodiVideoDB():
|
||||||
#update the checksum in emby table
|
#update the checksum in emby table
|
||||||
cursor.execute("UPDATE emby SET checksum = ? WHERE emby_id = ?", (API().getChecksum(MBitem),MBitem["Id"]))
|
cursor.execute("UPDATE emby SET checksum = ? WHERE emby_id = ?", (API().getChecksum(MBitem),MBitem["Id"]))
|
||||||
|
|
||||||
|
|
||||||
#update or insert actors
|
#update or insert actors
|
||||||
self.AddPeopleToMedia(idMVideo,MBitem.get("People"),"musicvideo", connection, cursor)
|
self.AddPeopleToMedia(idMVideo,MBitem.get("People"),"musicvideo", connection, cursor)
|
||||||
|
|
||||||
#update artwork
|
# Update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "musicvideo"), idMVideo, "musicvideo", "thumb", cursor)
|
self.textureCache.addArtwork(API().getAllArtwork(MBitem), idMVideo, "musicvideo", 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
|
#update genres
|
||||||
self.AddGenresToMedia(idMVideo, genres, "musicvideo", cursor)
|
self.AddGenresToMedia(idMVideo, genres, "musicvideo", cursor)
|
||||||
|
@ -546,6 +533,9 @@ class WriteKodiVideoDB():
|
||||||
|
|
||||||
self.AddTagsToMedia(showid, tags, "tvshow", cursor)
|
self.AddTagsToMedia(showid, tags, "tvshow", cursor)
|
||||||
|
|
||||||
|
# Update artwork
|
||||||
|
self.textureCache.addArtwork(API().getAllArtwork(MBitem), showid, "tvshow", cursor)
|
||||||
|
|
||||||
# Update or insert people
|
# Update or insert people
|
||||||
self.AddPeopleToMedia(showid, MBitem.get('People'),"tvshow", connection, cursor)
|
self.AddPeopleToMedia(showid, MBitem.get('People'),"tvshow", connection, cursor)
|
||||||
|
|
||||||
|
@ -555,16 +545,6 @@ class WriteKodiVideoDB():
|
||||||
# Update studios
|
# Update studios
|
||||||
self.AddStudiosToMedia(showid, studios, "tvshow", cursor)
|
self.AddStudiosToMedia(showid, studios, "tvshow", cursor)
|
||||||
|
|
||||||
# Update artwork
|
|
||||||
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
|
# Update season details
|
||||||
self.updateSeasons(embyId, showid, connection, cursor)
|
self.updateSeasons(embyId, showid, connection, cursor)
|
||||||
|
|
||||||
|
@ -723,7 +703,8 @@ class WriteKodiVideoDB():
|
||||||
self.AddStreamDetailsToMedia(API().getMediaStreams(MBitem), runtime, fileid, cursor)
|
self.AddStreamDetailsToMedia(API().getMediaStreams(MBitem), runtime, fileid, cursor)
|
||||||
|
|
||||||
# Update artwork
|
# Update artwork
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Primary", mediaType = "episode"), episodeid, "episode", "thumb", cursor)
|
artworks = API().getAllArtwork(MBitem)
|
||||||
|
self.textureCache.addOrUpdateArt(artworks['Primary'], episodeid, "episode", "thumb", cursor)
|
||||||
|
|
||||||
# Set resume point and round to 6th decimal
|
# Set resume point and round to 6th decimal
|
||||||
resume = round(float(timeInfo.get('ResumeTime')), 6)
|
resume = round(float(timeInfo.get('ResumeTime')), 6)
|
||||||
|
@ -764,49 +745,38 @@ class WriteKodiVideoDB():
|
||||||
|
|
||||||
def updateSeasons(self, embyTvShowId, kodiTvShowId, connection, cursor):
|
def updateSeasons(self, embyTvShowId, kodiTvShowId, connection, cursor):
|
||||||
|
|
||||||
|
textureCache = self.textureCache
|
||||||
seasonData = ReadEmbyDB().getTVShowSeasons(embyTvShowId)
|
seasonData = ReadEmbyDB().getTVShowSeasons(embyTvShowId)
|
||||||
|
|
||||||
if seasonData: # Verify every season
|
for season in seasonData:
|
||||||
for season in seasonData:
|
|
||||||
|
|
||||||
seasonNum = season.get('IndexNumber')
|
seasonNum = season.get('IndexNumber')
|
||||||
|
|
||||||
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?", (kodiTvShowId, seasonNum,))
|
|
||||||
try:
|
|
||||||
seasonid = cursor.fetchone()[0]
|
|
||||||
except: # Create the season
|
|
||||||
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
|
||||||
seasonid = cursor.fetchone()[0] + 1
|
|
||||||
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
|
|
||||||
cursor.execute(query, (seasonid, kodiTvShowId, seasonNum))
|
|
||||||
finally: # Update artwork
|
|
||||||
imageUrl = API().getArtwork(season, "Thumb", mediaType = "season")
|
|
||||||
self.addOrUpdateArt(imageUrl, seasonid, "season", "landscape", cursor)
|
|
||||||
|
|
||||||
imageUrl = API().getArtwork(season, "Primary", mediaType = "season")
|
|
||||||
self.addOrUpdateArt(imageUrl, seasonid, "season", "poster", cursor)
|
|
||||||
|
|
||||||
imageUrl = API().getArtwork(season, "Banner", mediaType = "season")
|
|
||||||
self.addOrUpdateArt(imageUrl, seasonid, "season", "banner", cursor)
|
|
||||||
|
|
||||||
imageUrl = API().getArtwork(season, "Backdrop", mediaType = "season")
|
|
||||||
self.addOrUpdateArt(imageUrl, seasonid, "season", "fanart", cursor)
|
|
||||||
|
|
||||||
# All season entry
|
|
||||||
MBitem = ReadEmbyDB().getFullItem(embyTvShowId)
|
|
||||||
seasonNum = -1
|
|
||||||
|
|
||||||
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?", (kodiTvShowId, seasonNum,))
|
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?", (kodiTvShowId, seasonNum,))
|
||||||
try:
|
try:
|
||||||
seasonid = cursor.fetchone()[0]
|
seasonid = cursor.fetchone()[0]
|
||||||
except: # Create all season entry
|
except: # Create the season
|
||||||
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
||||||
seasonid = cursor.fetchone()[0] + 1
|
seasonid = cursor.fetchone()[0] + 1
|
||||||
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
|
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
|
||||||
cursor.execute(query, (seasonid, kodiTvShowId, seasonNum))
|
cursor.execute(query, (seasonid, kodiTvShowId, seasonNum))
|
||||||
finally: # Update the artwork
|
finally: # Update artwork
|
||||||
imageUrl = API().getArtwork(MBitem, "Primary", mediaType = "season")
|
textureCache.addArtwork(API().getAllArtwork(season), seasonid, "season", cursor)
|
||||||
self.addOrUpdateArt(imageUrl, seasonid, "season", "poster", cursor)
|
|
||||||
|
# All season entry
|
||||||
|
MBitem = ReadEmbyDB().getFullItem(embyTvShowId)
|
||||||
|
seasonNum = -1
|
||||||
|
|
||||||
|
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?", (kodiTvShowId, seasonNum,))
|
||||||
|
try:
|
||||||
|
seasonid = cursor.fetchone()[0]
|
||||||
|
except: # Create all season entry
|
||||||
|
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
||||||
|
seasonid = cursor.fetchone()[0] + 1
|
||||||
|
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
|
||||||
|
cursor.execute(query, (seasonid, kodiTvShowId, seasonNum))
|
||||||
|
finally: # Update the artwork
|
||||||
|
textureCache.addArtwork(API().getAllArtwork(MBitem), seasonid, "season", cursor)
|
||||||
|
|
||||||
def addOrUpdateArt(self, imageUrl, kodiId, mediaType, imageType, cursor):
|
def addOrUpdateArt(self, imageUrl, kodiId, mediaType, imageType, cursor):
|
||||||
|
|
||||||
|
@ -907,7 +877,7 @@ class WriteKodiVideoDB():
|
||||||
if "writing" in arttype:
|
if "writing" in arttype:
|
||||||
arttype = "writer"
|
arttype = "writer"
|
||||||
|
|
||||||
self.addOrUpdateArt(thumb, actorid, arttype, "thumb", cursor)
|
self.textureCache.addOrUpdateArt(thumb, actorid, arttype, "thumb", cursor)
|
||||||
|
|
||||||
# Link person to content in database
|
# Link person to content in database
|
||||||
if kodiVersion == 15 or kodiVersion == 16:
|
if kodiVersion == 15 or kodiVersion == 16:
|
||||||
|
|
Loading…
Reference in a new issue