Moving getallartworks to PlexAPI
This commit is contained in:
parent
76c9b21dfb
commit
1e7acfc927
3 changed files with 125 additions and 21 deletions
|
@ -603,12 +603,12 @@ class PlexAPI():
|
||||||
"""
|
"""
|
||||||
# Get addon infos
|
# Get addon infos
|
||||||
xargs = dict()
|
xargs = dict()
|
||||||
xargs['User-agent'] = 'PlexKodiConnect'
|
xargs['User-agent'] = self.addonName
|
||||||
xargs['X-Plex-Device'] = self.deviceName
|
xargs['X-Plex-Device'] = self.deviceName
|
||||||
# xargs['X-Plex-Model'] = ''
|
# xargs['X-Plex-Model'] = ''
|
||||||
xargs['X-Plex-Platform'] = self.platform
|
xargs['X-Plex-Platform'] = self.platform
|
||||||
xargs['X-Plex-Client-Platform'] = self.platform
|
xargs['X-Plex-Client-Platform'] = self.platform
|
||||||
xargs['X-Plex-Product'] = 'PlexKodiConnect'
|
xargs['X-Plex-Product'] = self.addonName
|
||||||
xargs['X-Plex-Version'] = self.plexversion
|
xargs['X-Plex-Version'] = self.plexversion
|
||||||
xargs['X-Plex-Client-Identifier'] = self.clientId
|
xargs['X-Plex-Client-Identifier'] = self.clientId
|
||||||
if options:
|
if options:
|
||||||
|
@ -1720,3 +1720,99 @@ class API():
|
||||||
'audio': audiotracks,
|
'audio': audiotracks,
|
||||||
'subtitle': subtitlelanguages
|
'subtitle': subtitlelanguages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getAllArtwork(self, item, parentInfo=False):
|
||||||
|
|
||||||
|
server = self.server
|
||||||
|
|
||||||
|
id = item['key']
|
||||||
|
|
||||||
|
maxHeight = 10000
|
||||||
|
maxWidth = 10000
|
||||||
|
customquery = ""
|
||||||
|
|
||||||
|
if utils.settings('compressArt') == "true":
|
||||||
|
customquery = "&Quality=90"
|
||||||
|
|
||||||
|
if utils.settings('enableCoverArt') == "false":
|
||||||
|
customquery += "&EnableImageEnhancers=false"
|
||||||
|
|
||||||
|
allartworks = {
|
||||||
|
|
||||||
|
'Primary': "",
|
||||||
|
'Art': "",
|
||||||
|
'Banner': "",
|
||||||
|
'Logo': "",
|
||||||
|
'Thumb': "",
|
||||||
|
'Disc': "",
|
||||||
|
'Backdrop': []
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process backdrops
|
||||||
|
# Get background artwork URL
|
||||||
|
try:
|
||||||
|
background = item['art']
|
||||||
|
background = "%s%s" % (server, background)
|
||||||
|
except KeyError:
|
||||||
|
background = ""
|
||||||
|
allartworks['Backdrop'].append(background)
|
||||||
|
# Get primary "thumb" pictures:
|
||||||
|
try:
|
||||||
|
primary = item['thumb']
|
||||||
|
primary = "%s%s" % (server, primary)
|
||||||
|
except KeyError:
|
||||||
|
primary = ""
|
||||||
|
allartworks['Primary'] = primary
|
||||||
|
|
||||||
|
# Process parent items if the main item is missing artwork
|
||||||
|
if parentInfo:
|
||||||
|
|
||||||
|
# Process parent 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/emby/Items/%s/Images/Backdrop/%s?"
|
||||||
|
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
|
||||||
|
% (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"
|
||||||
|
% (server, parentId, parentart,
|
||||||
|
maxWidth, maxHeight, parentTag, customquery))
|
||||||
|
allartworks[parentart] = artwork
|
||||||
|
|
||||||
|
# Parent album works a bit differently
|
||||||
|
if not allartworks['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"
|
||||||
|
% (server, parentId, maxWidth, maxHeight, parentTag, customquery))
|
||||||
|
allartworks['Primary'] = artwork
|
||||||
|
|
||||||
|
return allartworks
|
|
@ -216,7 +216,6 @@ class Artwork():
|
||||||
# We don't need the result
|
# We don't need the result
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
|
|
||||||
def addArtwork(self, artwork, kodiId, mediaType, cursor):
|
def addArtwork(self, artwork, kodiId, mediaType, cursor):
|
||||||
# Kodi conversion table
|
# Kodi conversion table
|
||||||
kodiart = {
|
kodiart = {
|
||||||
|
@ -428,7 +427,9 @@ class Artwork():
|
||||||
|
|
||||||
server = self.server
|
server = self.server
|
||||||
|
|
||||||
id = item['key']
|
id = item['Id']
|
||||||
|
artworks = item['ImageTags']
|
||||||
|
backdrops = item['BackdropImageTags']
|
||||||
|
|
||||||
maxHeight = 10000
|
maxHeight = 10000
|
||||||
maxWidth = 10000
|
maxWidth = 10000
|
||||||
|
@ -452,20 +453,26 @@ class Artwork():
|
||||||
}
|
}
|
||||||
|
|
||||||
# Process backdrops
|
# Process backdrops
|
||||||
# Get background artwork URL
|
backdropIndex = 0
|
||||||
try:
|
for backdroptag in backdrops:
|
||||||
background = item['art']
|
artwork = (
|
||||||
background = "%s%s" % (server, background)
|
"%s/emby/Items/%s/Images/Backdrop/%s?"
|
||||||
except KeyError:
|
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
|
||||||
background = ""
|
% (server, id, backdropIndex,
|
||||||
allartworks['Backdrop'].append(background)
|
maxWidth, maxHeight, backdroptag, customquery))
|
||||||
# Get primary "thumb" pictures:
|
allartworks['Backdrop'].append(artwork)
|
||||||
try:
|
backdropIndex += 1
|
||||||
primary = item['thumb']
|
|
||||||
primary = "%s%s" % (server, primary)
|
# Process the rest of the artwork
|
||||||
except KeyError:
|
for art in artworks:
|
||||||
primary = ""
|
# Filter backcover
|
||||||
allartworks['Primary'] = primary
|
if art != "BoxRear":
|
||||||
|
tag = artworks[art]
|
||||||
|
artwork = (
|
||||||
|
"%s/emby/Items/%s/Images/%s/0?"
|
||||||
|
"MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s"
|
||||||
|
% (server, id, art, maxWidth, maxHeight, tag, customquery))
|
||||||
|
allartworks[art] = artwork
|
||||||
|
|
||||||
# Process parent items if the main item is missing artwork
|
# Process parent items if the main item is missing artwork
|
||||||
if parentInfo:
|
if parentInfo:
|
||||||
|
|
|
@ -444,7 +444,8 @@ class Movies(Items):
|
||||||
# Process genres
|
# Process genres
|
||||||
kodi_db.addGenres(movieid, genres, "movie")
|
kodi_db.addGenres(movieid, genres, "movie")
|
||||||
# Process artwork
|
# Process artwork
|
||||||
artwork.addArtwork(artwork.getAllArtwork(item), movieid, "movie", kodicursor)
|
allartworks = API.getAllArtwork()
|
||||||
|
artwork.addArtwork(allartworks, movieid, "movie", kodicursor)
|
||||||
# Process stream details
|
# Process stream details
|
||||||
streams = API.getMediaStreams()
|
streams = API.getMediaStreams()
|
||||||
kodi_db.addStreams(fileid, streams, runtime)
|
kodi_db.addStreams(fileid, streams, runtime)
|
||||||
|
|
Loading…
Reference in a new issue