mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Add thumbnails to notification options
This commit is contained in:
parent
014cac7789
commit
beb8df9dda
3 changed files with 32 additions and 13 deletions
|
@ -2171,6 +2171,22 @@
|
||||||
<td><strong>{grandparent_rating_key}</strong></td>
|
<td><strong>{grandparent_rating_key}</strong></td>
|
||||||
<td>The unique identifier for the TV show or artist.</td>
|
<td>The unique identifier for the TV show or artist.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>{thumb}</strong></td>
|
||||||
|
<td>The Plex thumbnail for the movie or episode.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>{parent_thumb}</strong></td>
|
||||||
|
<td>The Plex thumbnail for the season or album.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>{grandparent_thumb}</strong></td>
|
||||||
|
<td>The Plex thumbnail for the TV show or artist.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>{poster_thumb}</strong></td>
|
||||||
|
<td>The Plex thumbnail for the poster image.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table class="notification-params">
|
<table class="notification-params">
|
||||||
|
|
|
@ -406,24 +406,24 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
metadata['lastfm_url'] = 'https://www.last.fm/music/' + metadata['lastfm_id']
|
metadata['lastfm_url'] = 'https://www.last.fm/music/' + metadata['lastfm_id']
|
||||||
|
|
||||||
if metadata['media_type'] in ('movie', 'show', 'artist'):
|
if metadata['media_type'] in ('movie', 'show', 'artist'):
|
||||||
thumb = metadata['thumb']
|
poster_thumb = metadata['thumb']
|
||||||
poster_key = metadata['rating_key']
|
poster_key = metadata['rating_key']
|
||||||
poster_title = metadata['title']
|
poster_title = metadata['title']
|
||||||
elif metadata['media_type'] in ('season', 'album'):
|
elif metadata['media_type'] in ('season', 'album'):
|
||||||
thumb = metadata['thumb'] or metadata['parent_thumb']
|
poster_thumb = metadata['thumb'] or metadata['parent_thumb']
|
||||||
poster_key = metadata['rating_key']
|
poster_key = metadata['rating_key']
|
||||||
poster_title = '%s - %s' % (metadata['parent_title'],
|
poster_title = '%s - %s' % (metadata['parent_title'],
|
||||||
metadata['title'])
|
metadata['title'])
|
||||||
elif metadata['media_type'] in ('episode', 'track'):
|
elif metadata['media_type'] in ('episode', 'track'):
|
||||||
thumb = metadata['parent_thumb'] or metadata['grandparent_thumb']
|
poster_thumb = metadata['parent_thumb'] or metadata['grandparent_thumb']
|
||||||
poster_key = metadata['parent_rating_key']
|
poster_key = metadata['parent_rating_key']
|
||||||
poster_title = '%s - %s' % (metadata['grandparent_title'],
|
poster_title = '%s - %s' % (metadata['grandparent_title'],
|
||||||
metadata['parent_title'])
|
metadata['parent_title'])
|
||||||
else:
|
else:
|
||||||
thumb = ''
|
poster_thumb = ''
|
||||||
|
|
||||||
if plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
|
if plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
|
||||||
poster_info = get_poster_info(thumb=thumb, poster_key=poster_key, poster_title=poster_title)
|
poster_info = get_poster_info(poster_thumb=poster_thumb, poster_key=poster_key, poster_title=poster_title)
|
||||||
metadata.update(poster_info)
|
metadata.update(poster_info)
|
||||||
|
|
||||||
if plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT and metadata['media_type'] in ('show', 'artist'):
|
if plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT and metadata['media_type'] in ('show', 'artist'):
|
||||||
|
@ -629,7 +629,10 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
'rating_key': metadata['rating_key'],
|
'rating_key': metadata['rating_key'],
|
||||||
'parent_rating_key': metadata['parent_rating_key'],
|
'parent_rating_key': metadata['parent_rating_key'],
|
||||||
'grandparent_rating_key': metadata['grandparent_rating_key'],
|
'grandparent_rating_key': metadata['grandparent_rating_key'],
|
||||||
'thumb': thumb
|
'thumb': metadata['thumb'],
|
||||||
|
'parent_thumb': metadata['parent_thumb'],
|
||||||
|
'grandparent_thumb': metadata['grandparent_thumb'],
|
||||||
|
'poster_thumb': poster_thumb
|
||||||
}
|
}
|
||||||
|
|
||||||
return available_params
|
return available_params
|
||||||
|
@ -822,27 +825,27 @@ def format_group_index(group_keys):
|
||||||
return ','.join(num) or '0', ','.join(num00) or '00'
|
return ','.join(num) or '0', ','.join(num00) or '00'
|
||||||
|
|
||||||
|
|
||||||
def get_poster_info(thumb, poster_key, poster_title):
|
def get_poster_info(poster_thumb, poster_key, poster_title):
|
||||||
# Try to retrieve poster info from the database
|
# Try to retrieve poster info from the database
|
||||||
data_factory = datafactory.DataFactory()
|
data_factory = datafactory.DataFactory()
|
||||||
poster_info = data_factory.get_poster_info(rating_key=poster_key)
|
poster_info = data_factory.get_poster_info(rating_key=poster_key)
|
||||||
|
|
||||||
# If no previous poster info
|
# If no previous poster info
|
||||||
if not poster_info and thumb:
|
if not poster_info and poster_thumb:
|
||||||
try:
|
try:
|
||||||
thread_name = str(threading.current_thread().ident)
|
thread_name = str(threading.current_thread().ident)
|
||||||
poster_file = os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-%s' % thread_name)
|
poster_file = os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-%s' % thread_name)
|
||||||
|
|
||||||
# Retrieve the poster from Plex and cache to file
|
# Retrieve the poster from Plex and cache to file
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
result = pms_connect.get_image(img=thumb)
|
result = pms_connect.get_image(img=poster_thumb)
|
||||||
if result and result[0]:
|
if result and result[0]:
|
||||||
with open(poster_file, 'wb') as f:
|
with open(poster_file, 'wb') as f:
|
||||||
f.write(result[0])
|
f.write(result[0])
|
||||||
else:
|
else:
|
||||||
raise Exception(u'PMS image request failed')
|
raise Exception(u'PMS image request failed')
|
||||||
|
|
||||||
# Upload thumb to Imgur and get link
|
# Upload poster_thumb to Imgur and get link
|
||||||
poster_url = helpers.uploadToImgur(poster_file, poster_title)
|
poster_url = helpers.uploadToImgur(poster_file, poster_title)
|
||||||
|
|
||||||
# Create poster info
|
# Create poster info
|
||||||
|
|
|
@ -709,15 +709,15 @@ class ANDROIDAPP(Notifier):
|
||||||
|
|
||||||
if kwargs.get('parameters', {}).get('media_type'):
|
if kwargs.get('parameters', {}).get('media_type'):
|
||||||
pretty_metadata = PrettyMetadata(kwargs['parameters'])
|
pretty_metadata = PrettyMetadata(kwargs['parameters'])
|
||||||
thumb = pretty_metadata.parameters.get('thumb','')
|
poster_thumb = pretty_metadata.parameters.get('poster_thumb','')
|
||||||
else:
|
else:
|
||||||
thumb = ''
|
poster_thumb = ''
|
||||||
|
|
||||||
plaintext_data = {'notification_id': notification_id,
|
plaintext_data = {'notification_id': notification_id,
|
||||||
'subject': subject.encode("utf-8"),
|
'subject': subject.encode("utf-8"),
|
||||||
'body': body.encode("utf-8"),
|
'body': body.encode("utf-8"),
|
||||||
'priority': self.config['priority'],
|
'priority': self.config['priority'],
|
||||||
'thumb': thumb}
|
'poster_thumb': poster_thumb}
|
||||||
|
|
||||||
#logger.debug("Plaintext data: {}".format(plaintext_data))
|
#logger.debug("Plaintext data: {}".format(plaintext_data))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue