mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Add return_hash to pms_image_proxy API
This commit is contained in:
parent
1eee03fa8f
commit
dd3f75f154
4 changed files with 35 additions and 21 deletions
10
API.md
10
API.md
|
@ -1140,7 +1140,8 @@ Returns:
|
||||||
"video_language_code": "",
|
"video_language_code": "",
|
||||||
"video_profile": "high",
|
"video_profile": "high",
|
||||||
"video_ref_frames": "4",
|
"video_ref_frames": "4",
|
||||||
"video_width": "1920"
|
"video_width": "1920",
|
||||||
|
"selected": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"audio_bitrate": "384",
|
"audio_bitrate": "384",
|
||||||
|
@ -1153,7 +1154,8 @@ Returns:
|
||||||
"audio_profile": "",
|
"audio_profile": "",
|
||||||
"audio_sample_rate": "48000",
|
"audio_sample_rate": "48000",
|
||||||
"id": "511664",
|
"id": "511664",
|
||||||
"type": "2"
|
"type": "2",
|
||||||
|
"selected": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "511953",
|
"id": "511953",
|
||||||
|
@ -1164,7 +1166,8 @@ Returns:
|
||||||
"subtitle_language": "English",
|
"subtitle_language": "English",
|
||||||
"subtitle_language_code": "eng",
|
"subtitle_language_code": "eng",
|
||||||
"subtitle_location": "external",
|
"subtitle_location": "external",
|
||||||
"type": "3"
|
"type": "3",
|
||||||
|
"selected": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2496,6 +2499,7 @@ Optional parameters:
|
||||||
img_format (str): png
|
img_format (str): png
|
||||||
fallback (str): "poster", "cover", "art"
|
fallback (str): "poster", "cover", "art"
|
||||||
refresh (bool): True or False whether to refresh the image cache
|
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
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
|
|
|
@ -596,8 +596,9 @@ General optional parameters:
|
||||||
return
|
return
|
||||||
|
|
||||||
elif self._api_cmd == 'pms_image_proxy':
|
elif self._api_cmd == 'pms_image_proxy':
|
||||||
cherrypy.response.headers['Content-Type'] = 'image/jpeg'
|
if 'return_hash' not in self._api_kwargs:
|
||||||
return out['response']['data']
|
cherrypy.response.headers['Content-Type'] = 'image/jpeg'
|
||||||
|
return out['response']['data']
|
||||||
|
|
||||||
if self._api_out_type == 'json':
|
if self._api_out_type == 'json':
|
||||||
cherrypy.response.headers['Content-Type'] = 'application/json;charset=UTF-8'
|
cherrypy.response.headers['Content-Type'] = 'application/json;charset=UTF-8'
|
||||||
|
|
|
@ -1256,7 +1256,8 @@ def get_img_info(img=None, rating_key=None, title='', width=1000, height=1500,
|
||||||
|
|
||||||
|
|
||||||
def set_hash_image_info(img=None, rating_key=None, width=750, height=1000,
|
def set_hash_image_info(img=None, rating_key=None, width=750, height=1000,
|
||||||
opacity=100, background='000000', blur=0, fallback=None):
|
opacity=100, background='000000', blur=0, fallback=None,
|
||||||
|
add_to_db=True):
|
||||||
if not rating_key and not img:
|
if not rating_key and not img:
|
||||||
return fallback
|
return fallback
|
||||||
|
|
||||||
|
@ -1274,18 +1275,19 @@ def set_hash_image_info(img=None, rating_key=None, width=750, height=1000,
|
||||||
plexpy.CONFIG.PMS_UUID, img, rating_key, width, height, opacity, background, blur, fallback)
|
plexpy.CONFIG.PMS_UUID, img, rating_key, width, height, opacity, background, blur, fallback)
|
||||||
img_hash = hashlib.sha256(img_string).hexdigest()
|
img_hash = hashlib.sha256(img_string).hexdigest()
|
||||||
|
|
||||||
keys = {'img_hash': img_hash}
|
if add_to_db:
|
||||||
values = {'img': img,
|
keys = {'img_hash': img_hash}
|
||||||
'rating_key': rating_key,
|
values = {'img': img,
|
||||||
'width': width,
|
'rating_key': rating_key,
|
||||||
'height': height,
|
'width': width,
|
||||||
'opacity': opacity,
|
'height': height,
|
||||||
'background': background,
|
'opacity': opacity,
|
||||||
'blur': blur,
|
'background': background,
|
||||||
'fallback': fallback}
|
'blur': blur,
|
||||||
|
'fallback': fallback}
|
||||||
|
|
||||||
db = database.MonitorDatabase()
|
db = database.MonitorDatabase()
|
||||||
db.upsert('image_hash_lookup', key_dict=keys, value_dict=values)
|
db.upsert('image_hash_lookup', key_dict=keys, value_dict=values)
|
||||||
|
|
||||||
return img_hash
|
return img_hash
|
||||||
|
|
||||||
|
|
|
@ -4031,7 +4031,7 @@ class WebInterface(object):
|
||||||
return self.real_pms_image_proxy(**kwargs)
|
return self.real_pms_image_proxy(**kwargs)
|
||||||
|
|
||||||
@addtoapi('pms_image_proxy')
|
@addtoapi('pms_image_proxy')
|
||||||
def real_pms_image_proxy(self, img='', rating_key=None, width=0, height=0,
|
def real_pms_image_proxy(self, img=None, rating_key=None, width=750, height=1000,
|
||||||
opacity=100, background='000000', blur=0, img_format='png',
|
opacity=100, background='000000', blur=0, img_format='png',
|
||||||
fallback=None, refresh=False, clip=False, **kwargs):
|
fallback=None, refresh=False, clip=False, **kwargs):
|
||||||
""" Gets an image from the PMS and saves it to the image cache directory.
|
""" Gets an image from the PMS and saves it to the image cache directory.
|
||||||
|
@ -4051,6 +4051,7 @@ class WebInterface(object):
|
||||||
img_format (str): png
|
img_format (str): png
|
||||||
fallback (str): "poster", "cover", "art"
|
fallback (str): "poster", "cover", "art"
|
||||||
refresh (bool): True or False whether to refresh the image cache
|
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
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
|
@ -4060,6 +4061,8 @@ class WebInterface(object):
|
||||||
logger.warn('No image input received.')
|
logger.warn('No image input received.')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
return_hash = (kwargs.get('return_hash') == 'true')
|
||||||
|
|
||||||
if rating_key and not img:
|
if rating_key and not img:
|
||||||
if fallback == 'art':
|
if fallback == 'art':
|
||||||
img = '/library/metadata/{}/art'.format(rating_key)
|
img = '/library/metadata/{}/art'.format(rating_key)
|
||||||
|
@ -4070,9 +4073,13 @@ class WebInterface(object):
|
||||||
img = '/'.join(img_split[:5])
|
img = '/'.join(img_split[:5])
|
||||||
rating_key = rating_key or img_split[3]
|
rating_key = rating_key or img_split[3]
|
||||||
|
|
||||||
img_string = '{}.{}.{}.{}.{}.{}.{}.{}'.format(
|
img_hash = notification_handler.set_hash_image_info(
|
||||||
plexpy.CONFIG.PMS_UUID, img, rating_key, width, height, opacity, background, blur, fallback)
|
img=img, rating_key=rating_key, width=width, height=height,
|
||||||
img_hash = hashlib.sha256(img_string).hexdigest()
|
opacity=opacity, background=background, blur=blur, fallback=fallback,
|
||||||
|
add_to_db=return_hash)
|
||||||
|
|
||||||
|
if return_hash:
|
||||||
|
return {'img_hash': img_hash}
|
||||||
|
|
||||||
fp = '{}.{}'.format(img_hash, img_format) # we want to be able to preview the thumbs
|
fp = '{}.{}'.format(img_hash, img_format) # we want to be able to preview the thumbs
|
||||||
c_dir = os.path.join(plexpy.CONFIG.CACHE_DIR, 'images')
|
c_dir = os.path.join(plexpy.CONFIG.CACHE_DIR, 'images')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue