mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 21:03:21 -07:00
Update pms_image_proxy to work with web URLs
This commit is contained in:
parent
26f10b2c3d
commit
13a45facf9
4 changed files with 30 additions and 44 deletions
|
@ -34,11 +34,21 @@ DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png"
|
|||
DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png"
|
||||
DEFAULT_COVER_THUMB = "interfaces/default/images/cover.png"
|
||||
DEFAULT_ART = "interfaces/default/images/art.png"
|
||||
DEFAULT_LIVE_TV_POSTER_THUMB = "interfaces/default/images/poster-live.png"
|
||||
DEFAULT_LIVE_TV_ART = "interfaces/default/images/art-live.png"
|
||||
|
||||
ONLINE_POSTER_THUMB = "https://tautulli.com/images/poster.png"
|
||||
ONLINE_COVER_THUMB = "https://tautulli.com/images/cover.png"
|
||||
ONLINE_ART = "https://tautulli.com/images/art.png"
|
||||
|
||||
DEFAULT_IMAGES = {
|
||||
'poster': DEFAULT_POSTER_THUMB,
|
||||
'cover': DEFAULT_COVER_THUMB,
|
||||
'art': DEFAULT_ART,
|
||||
'poster-live': DEFAULT_LIVE_TV_POSTER_THUMB,
|
||||
'poster-art': DEFAULT_LIVE_TV_ART
|
||||
}
|
||||
|
||||
MEDIA_TYPE_HEADERS = {
|
||||
'movie': 'Movies',
|
||||
'show': 'TV Shows',
|
||||
|
|
|
@ -2694,10 +2694,14 @@ class PmsConnect(object):
|
|||
height = height or 1500
|
||||
|
||||
if img:
|
||||
if refresh:
|
||||
web_img = img.startswith('http')
|
||||
|
||||
if refresh and not web_img:
|
||||
img = '{}/{}'.format(img.rstrip('/'), int(time.time()))
|
||||
|
||||
if clip:
|
||||
if web_img:
|
||||
params = {'url': '%s' % img}
|
||||
elif clip:
|
||||
params = {'url': '%s&%s' % (img, urllib.urlencode({'X-Plex-Token': self.token}))}
|
||||
else:
|
||||
params = {'url': 'http://127.0.0.1:32400%s?%s' % (img, urllib.urlencode({'X-Plex-Token': self.token}))}
|
||||
|
|
|
@ -4038,7 +4038,7 @@ class WebInterface(object):
|
|||
background (str): 282828
|
||||
blur (str): 3
|
||||
img_format (str): png
|
||||
fallback (str): "poster", "cover", "art"
|
||||
fallback (str): "poster", "cover", "art", "poster-live", "poster-art"
|
||||
refresh (bool): True or False whether to refresh the image cache
|
||||
return_hash (bool): True or False to return the self-hosted image hash instead of the image
|
||||
|
||||
|
@ -4058,9 +4058,12 @@ class WebInterface(object):
|
|||
else:
|
||||
img = '/library/metadata/{}/thumb'.format(rating_key)
|
||||
|
||||
img_split = img.split('/')
|
||||
img = '/'.join(img_split[:5])
|
||||
rating_key = rating_key or img_split[3]
|
||||
web_img = img.startswith('http')
|
||||
|
||||
if not web_img:
|
||||
img_split = img.split('/')
|
||||
img = '/'.join(img_split[:5])
|
||||
rating_key = rating_key or img_split[3]
|
||||
|
||||
img_hash = notification_handler.set_hash_image_info(
|
||||
img=img, rating_key=rating_key, width=width, height=height,
|
||||
|
@ -4111,15 +4114,8 @@ class WebInterface(object):
|
|||
|
||||
except Exception as e:
|
||||
logger.warn(u'Failed to get image %s, falling back to %s.' % (img, fallback))
|
||||
fbi = None
|
||||
if fallback == 'poster':
|
||||
fbi = common.DEFAULT_POSTER_THUMB
|
||||
elif fallback == 'cover':
|
||||
fbi = common.DEFAULT_COVER_THUMB
|
||||
elif fallback == 'art':
|
||||
fbi = common.DEFAULT_ART
|
||||
|
||||
if fbi:
|
||||
if fallback in common.DEFAULT_IMAGES:
|
||||
fbi = common.DEFAULT_IMAGES[fallback]
|
||||
fp = os.path.join(plexpy.PROG_DIR, 'data', fbi)
|
||||
return serve_file(path=fp, content_type='image/png')
|
||||
|
||||
|
@ -4137,14 +4133,8 @@ class WebInterface(object):
|
|||
|
||||
img_hash = args[0].split('.')[0]
|
||||
|
||||
if img_hash in ('poster', 'cover', 'art'):
|
||||
if img_hash == 'poster':
|
||||
fbi = common.DEFAULT_POSTER_THUMB
|
||||
elif img_hash == 'cover':
|
||||
fbi = common.DEFAULT_COVER_THUMB
|
||||
elif img_hash == 'art':
|
||||
fbi = common.DEFAULT_ART
|
||||
|
||||
if img_hash in common.DEFAULT_IMAGES:
|
||||
fbi = common.DEFAULT_IMAGES[img_hash]
|
||||
fp = os.path.join(plexpy.PROG_DIR, 'data', fbi)
|
||||
return serve_file(path=fp, content_type='image/png')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue