mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Add {stream_time}, {remaining_time}, and {progress_time} to notification options
This commit is contained in:
parent
3248e6500e
commit
14a90d84ec
4 changed files with 57 additions and 9 deletions
|
@ -1093,11 +1093,11 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
</tr>
|
||||
<tr>
|
||||
<td><strong>{datestamp}</strong></td>
|
||||
<td>The date the notification was triggered.</td>
|
||||
<td>The date (in date format) the notification was triggered.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{timestamp}</strong></td>
|
||||
<td>The time the notification was triggered.</td>
|
||||
<td>The time (in time format) the notification was triggered.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -1134,14 +1134,26 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<td><strong>{stream_duration}</strong></td>
|
||||
<td>The stream duration (in minutes) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{stream_time}</strong></td>
|
||||
<td>The stream duration (in time format) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{remaining_duration}</strong></td>
|
||||
<td>The remaining duration (in minutes) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{progress}</strong></td>
|
||||
<td><strong>{remaining_time}</strong></td>
|
||||
<td>The remaining duration (in time format) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{progress_duration}</strong></td>
|
||||
<td>The last reported offset (in minutes) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{progress_time}</strong></td>
|
||||
<td>The last reported offset (in time format) for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{progress_percent}</strong></td>
|
||||
<td>The last reported progress percent for the item.</td>
|
||||
|
@ -1222,6 +1234,10 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<td><strong>{transcode_audio_channels}</strong></td>
|
||||
<td>The audio channels of the transcoded media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{session_key}</strong></td>
|
||||
<td>The unique identifier for the session.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{user_id}</strong></td>
|
||||
<td>The unique identifier for the user.</td>
|
||||
|
|
|
@ -512,6 +512,7 @@ class Config(object):
|
|||
self.MOVIE_LOGGING_ENABLE = 0
|
||||
self.TV_LOGGING_ENABLE = 0
|
||||
self.CONFIG_VERSION = '1'
|
||||
|
||||
if self.CONFIG_VERSION == '1':
|
||||
# Change home_stats_cards to list
|
||||
if self.HOME_STATS_CARDS:
|
||||
|
@ -525,4 +526,20 @@ class Config(object):
|
|||
if 'library_statistics' in home_library_cards:
|
||||
home_library_cards.remove('library_statistics')
|
||||
self.HOME_LIBRARY_CARDS = home_library_cards
|
||||
self.CONFIG_VERSION = '2'
|
||||
self.CONFIG_VERSION = '2'
|
||||
|
||||
if self.CONFIG_VERSION == '2':
|
||||
self.NOTIFY_ON_START_SUBJECT_TEXT = self.NOTIFY_ON_START_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_START_BODY_TEXT = self.NOTIFY_ON_START_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_STOP_SUBJECT_TEXT = self.NOTIFY_ON_STOP_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_STOP_BODY_TEXT = self.NOTIFY_ON_STOP_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_PAUSE_SUBJECT_TEXT = self.NOTIFY_ON_PAUSE_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_PAUSE_BODY_TEXT = self.NOTIFY_ON_PAUSE_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_RESUME_SUBJECT_TEXT = self.NOTIFY_ON_RESUME_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_RESUME_BODY_TEXT = self.NOTIFY_ON_RESUME_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_BUFFER_SUBJECT_TEXT = self.NOTIFY_ON_BUFFER_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_BUFFER_BODY_TEXT = self.NOTIFY_ON_BUFFER_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_WATCHED_SUBJECT_TEXT = self.NOTIFY_ON_WATCHED_SUBJECT_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_ON_WATCHED_BODY_TEXT = self.NOTIFY_ON_WATCHED_BODY_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.NOTIFY_SCRIPTS_ARGS_TEXT = self.NOTIFY_SCRIPTS_ARGS_TEXT.replace('{progress}','{progress_duration}')
|
||||
self.CONFIG_VERSION = '3'
|
||||
|
|
|
@ -135,6 +135,15 @@ def convert_seconds(s):
|
|||
|
||||
return minutes
|
||||
|
||||
def convert_seconds_to_minutes(s):
|
||||
|
||||
if str(s).isdigit():
|
||||
minutes = round(float(s) / 60, 0)
|
||||
|
||||
return math.trunc(minutes)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def today():
|
||||
today = datetime.date.today()
|
||||
|
|
|
@ -446,14 +446,17 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
transcode_decision = 'Direct Play'
|
||||
|
||||
if state != 'play':
|
||||
stream_duration = int((time.time() - helpers.cast_to_float(session.get('started', 0)) -
|
||||
helpers.cast_to_float(session.get('paused_counter', 0))) / 60)
|
||||
stream_duration = helpers.convert_seconds_to_minutes(
|
||||
time.time() -
|
||||
helpers.cast_to_float(session.get('started', 0)) -
|
||||
helpers.cast_to_float(session.get('paused_counter', 0)))
|
||||
else:
|
||||
stream_duration = 0
|
||||
|
||||
view_offset = helpers.convert_milliseconds_to_minutes(session.get('view_offset', 0))
|
||||
duration = helpers.convert_milliseconds_to_minutes(metadata['duration'])
|
||||
progress_percent = helpers.get_percent(view_offset, duration)
|
||||
remaining_duration = duration - view_offset
|
||||
|
||||
# Fix metadata params for notify recently added grandparent
|
||||
if state == 'created' and plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT:
|
||||
|
@ -468,7 +471,7 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
artist_name = metadata['grandparent_title']
|
||||
album_name = metadata['parent_title']
|
||||
track_name = metadata['title']
|
||||
|
||||
|
||||
available_params = {# Global paramaters
|
||||
'server_name': server_name,
|
||||
'server_uptime': server_uptime,
|
||||
|
@ -482,8 +485,11 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
'player': session.get('player',''),
|
||||
'ip_address': session.get('ip_address','N/A'),
|
||||
'stream_duration': stream_duration,
|
||||
'remaining_duration': duration - view_offset,
|
||||
'progress': view_offset,
|
||||
'stream_time': arrow.get(stream_duration * 60).format(duration_format),
|
||||
'remaining_duration': remaining_duration,
|
||||
'remaining_time': arrow.get(remaining_duration * 60).format(duration_format),
|
||||
'progress_duration': view_offset,
|
||||
'progress_time': arrow.get(view_offset * 60).format(duration_format),
|
||||
'progress_percent': progress_percent,
|
||||
'container': session.get('container',''),
|
||||
'video_codec': session.get('video_codec',''),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue