mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 01:32:57 -07:00
Caches pms images to disk
This commit is contained in:
parent
5ddd4d045e
commit
7be651f5cf
3 changed files with 79 additions and 37 deletions
|
@ -1887,38 +1887,14 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
@requireAuth()
|
||||
def pms_image_proxy(self, img='', width='0', height='0', fallback=None, **kwargs):
|
||||
try:
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_image(img, width, height)
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_image(img, width, height, fallback)
|
||||
|
||||
if result:
|
||||
cherrypy.response.headers['Content-type'] = result[1]
|
||||
return result[0]
|
||||
except:
|
||||
logger.warn(u"Image proxy queried but errors occurred.")
|
||||
if fallback == 'poster':
|
||||
logger.info(u"Trying fallback image...")
|
||||
try:
|
||||
fallback_image = open(self.interface_dir + common.DEFAULT_POSTER_THUMB, 'rb')
|
||||
cherrypy.response.headers['Content-type'] = 'image/png'
|
||||
return fallback_image
|
||||
except IOError, e:
|
||||
logger.error(u"Unable to read fallback %s image: %s" % (fallback, e))
|
||||
elif fallback == 'cover':
|
||||
logger.info(u"Trying fallback image...")
|
||||
try:
|
||||
fallback_image = open(self.interface_dir + common.DEFAULT_COVER_THUMB, 'rb')
|
||||
cherrypy.response.headers['Content-type'] = 'image/png'
|
||||
return fallback_image
|
||||
except IOError, e:
|
||||
logger.error(u"Unable to read fallback %s image: %s" % (fallback, e))
|
||||
elif fallback == 'art':
|
||||
logger.info(u"Trying fallback image...")
|
||||
try:
|
||||
fallback_image = open(self.interface_dir + common.DEFAULT_ART, 'rb')
|
||||
cherrypy.response.headers['Content-type'] = 'image/png'
|
||||
return fallback_image
|
||||
except IOError, e:
|
||||
logger.error(u"Unable to read fallback %s image: %s" % (fallback, e))
|
||||
|
||||
else:
|
||||
return None
|
||||
|
||||
@cherrypy.expose
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue