mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Add date and time parameters for notifications and newsletters
This commit is contained in:
parent
37841b6e8c
commit
7387cb8322
3 changed files with 55 additions and 10 deletions
|
@ -307,10 +307,17 @@ NOTIFICATION_PARAMETERS = [
|
||||||
{'name': 'Server Version', 'type': 'str', 'value': 'server_version', 'description': 'The current version of your Plex Server.'},
|
{'name': 'Server Version', 'type': 'str', 'value': 'server_version', 'description': 'The current version of your Plex Server.'},
|
||||||
{'name': 'Server ID', 'type': 'str', 'value': 'server_machine_id', 'description': 'The unique identifier for your Plex Server.'},
|
{'name': 'Server ID', 'type': 'str', 'value': 'server_machine_id', 'description': 'The unique identifier for your Plex Server.'},
|
||||||
{'name': 'Action', 'type': 'str', 'value': 'action', 'description': 'The action that triggered the notification.'},
|
{'name': 'Action', 'type': 'str', 'value': 'action', 'description': 'The action that triggered the notification.'},
|
||||||
{'name': 'Week Number', 'type': 'int', 'value': 'week_number', 'description': 'The week number of the year when the notfication was triggered.'},
|
{'name': 'Current Year', 'type': 'int', 'value': 'current_year', 'description': 'The year when the notfication is triggered.'},
|
||||||
{'name': 'Datestamp', 'type': 'str', 'value': 'datestamp', 'description': 'The date (in date format) when the notification was triggered.'},
|
{'name': 'Current Month', 'type': 'int', 'value': 'current_month', 'description': 'The month when the notfication is triggered.', 'example': '1 to 12'},
|
||||||
{'name': 'Timestamp', 'type': 'str', 'value': 'timestamp', 'description': 'The time (in time format) when the notification was triggered.'},
|
{'name': 'Current Day', 'type': 'int', 'value': 'current_day', 'description': 'The day when the notfication is triggered.', 'example': '1 to 31'},
|
||||||
{'name': 'Unix Time', 'type': 'int', 'value': 'unixtime', 'description': 'The unix timestamp when the notification was triggered.'},
|
{'name': 'Current Hour', 'type': 'int', 'value': 'current_hour', 'description': 'The hour when the notfication is triggered.', 'example': '0 to 23'},
|
||||||
|
{'name': 'Current Minute', 'type': 'int', 'value': 'current_minute', 'description': 'The minute when the notfication is triggered.', 'example': '0 to 59'},
|
||||||
|
{'name': 'Current Second', 'type': 'int', 'value': 'current_second', 'description': 'The second when the notfication is triggered.', 'example': '0 to 59'},
|
||||||
|
{'name': 'Current Weekday', 'type': 'int', 'value': 'current_weekday', 'description': 'The ISO weekday when the notfication is triggered.', 'example': '1 (Mon) to 7 (Sun)'},
|
||||||
|
{'name': 'Current Week', 'type': 'int', 'value': 'current_week', 'description': 'The ISO week number when the notfication is triggered.', 'example': '1 to 52'},
|
||||||
|
{'name': 'Datestamp', 'type': 'str', 'value': 'datestamp', 'description': 'The date (in date format) when the notification is triggered.'},
|
||||||
|
{'name': 'Timestamp', 'type': 'str', 'value': 'timestamp', 'description': 'The time (in time format) when the notification is triggered.'},
|
||||||
|
{'name': 'Unix Time', 'type': 'int', 'value': 'unixtime', 'description': 'The unix timestamp when the notification is triggered.'},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -527,7 +534,14 @@ NEWSLETTER_PARAMETERS = [
|
||||||
{'name': 'Server Name', 'type': 'str', 'value': 'server_name', 'description': 'The name of your Plex Server.'},
|
{'name': 'Server Name', 'type': 'str', 'value': 'server_name', 'description': 'The name of your Plex Server.'},
|
||||||
{'name': 'Start Date', 'type': 'str', 'value': 'start_date', 'description': 'The start date of the newsletter.'},
|
{'name': 'Start Date', 'type': 'str', 'value': 'start_date', 'description': 'The start date of the newsletter.'},
|
||||||
{'name': 'End Date', 'type': 'str', 'value': 'end_date', 'description': 'The end date of the newsletter.'},
|
{'name': 'End Date', 'type': 'str', 'value': 'end_date', 'description': 'The end date of the newsletter.'},
|
||||||
{'name': 'Week Number', 'type': 'int', 'value': 'week_number', 'description': 'The week number of the year.'},
|
{'name': 'Current Year', 'type': 'int', 'value': 'current_year', 'description': 'The year of the start date of the newsletter.'},
|
||||||
|
{'name': 'Current Month', 'type': 'int', 'value': 'current_month', 'description': 'The month of the start date of the newsletter.', 'example': '1 to 12'},
|
||||||
|
{'name': 'Current Day', 'type': 'int', 'value': 'current_day', 'description': 'The day of the start date of the newsletter.', 'example': '1 to 31'},
|
||||||
|
{'name': 'Current Hour', 'type': 'int', 'value': 'current_hour', 'description': 'The hour of the start date of the newsletter.', 'example': '0 to 23'},
|
||||||
|
{'name': 'Current Minute', 'type': 'int', 'value': 'current_minute', 'description': 'The minute of the start date of the newsletter.', 'example': '0 to 59'},
|
||||||
|
{'name': 'Current Second', 'type': 'int', 'value': 'current_second', 'description': 'The second of the start date of the newsletter.', 'example': '0 to 59'},
|
||||||
|
{'name': 'Current Weekday', 'type': 'int', 'value': 'current_weekday', 'description': 'The ISO weekday of the start date of the newsletter.', 'example': '1 (Mon) to 7 (Sun)'},
|
||||||
|
{'name': 'Current Week', 'type': 'int', 'value': 'current_week', 'description': 'The ISO week number of the start date of the newsletter.', 'example': '1 to 52'},
|
||||||
{'name': 'Newsletter Time Frame', 'type': 'int', 'value': 'newsletter_time_frame', 'description': 'The time frame included in the newsletter.'},
|
{'name': 'Newsletter Time Frame', 'type': 'int', 'value': 'newsletter_time_frame', 'description': 'The time frame included in the newsletter.'},
|
||||||
{'name': 'Newsletter Time Frame Units', 'type': 'str', 'value': 'newsletter_time_frame_units', 'description': 'The time frame units included in the newsletter.'},
|
{'name': 'Newsletter Time Frame Units', 'type': 'str', 'value': 'newsletter_time_frame_units', 'description': 'The time frame units included in the newsletter.'},
|
||||||
{'name': 'Newsletter URL', 'type': 'str', 'value': 'newsletter_url', 'description': 'The self-hosted URL to the newsletter.'},
|
{'name': 'Newsletter URL', 'type': 'str', 'value': 'newsletter_url', 'description': 'The self-hosted URL to the newsletter.'},
|
||||||
|
|
|
@ -555,6 +555,14 @@ class Newsletter(object):
|
||||||
'server_name': plexpy.CONFIG.PMS_NAME,
|
'server_name': plexpy.CONFIG.PMS_NAME,
|
||||||
'start_date': self.start_date.format(date_format),
|
'start_date': self.start_date.format(date_format),
|
||||||
'end_date': self.end_date.format(date_format),
|
'end_date': self.end_date.format(date_format),
|
||||||
|
'current_year': self.start_date.year,
|
||||||
|
'current_month': self.start_date.month,
|
||||||
|
'current_day': self.start_date.day,
|
||||||
|
'current_hour': self.start_date.hour,
|
||||||
|
'current_minute': self.start_date.minute,
|
||||||
|
'current_second': self.start_date.second,
|
||||||
|
'current_weekday': self.start_date.isocalendar()[2],
|
||||||
|
'current_week': self.start_date.isocalendar()[1],
|
||||||
'week_number': self.start_date.isocalendar()[1],
|
'week_number': self.start_date.isocalendar()[1],
|
||||||
'newsletter_time_frame': self.config['time_frame'],
|
'newsletter_time_frame': self.config['time_frame'],
|
||||||
'newsletter_time_frame_units': self.config['time_frame_units'],
|
'newsletter_time_frame_units': self.config['time_frame_units'],
|
||||||
|
|
|
@ -701,6 +701,9 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
||||||
child_count = 1
|
child_count = 1
|
||||||
grandchild_count = 1
|
grandchild_count = 1
|
||||||
|
|
||||||
|
now = arrow.now()
|
||||||
|
now_iso = now.isocalendar()
|
||||||
|
|
||||||
available_params = {
|
available_params = {
|
||||||
# Global paramaters
|
# Global paramaters
|
||||||
'tautulli_version': common.RELEASE,
|
'tautulli_version': common.RELEASE,
|
||||||
|
@ -715,9 +718,17 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
||||||
'server_platform': plexpy.CONFIG.PMS_PLATFORM,
|
'server_platform': plexpy.CONFIG.PMS_PLATFORM,
|
||||||
'server_version': plexpy.CONFIG.PMS_VERSION,
|
'server_version': plexpy.CONFIG.PMS_VERSION,
|
||||||
'action': notify_action.split('on_')[-1],
|
'action': notify_action.split('on_')[-1],
|
||||||
'week_number': arrow.now().isocalendar()[1],
|
'current_year': now.year,
|
||||||
'datestamp': arrow.now().format(date_format),
|
'current_month': now.month,
|
||||||
'timestamp': arrow.now().format(time_format),
|
'current_day': now.day,
|
||||||
|
'current_hour': now.hour,
|
||||||
|
'current_minute': now.minute,
|
||||||
|
'current_second': now.second,
|
||||||
|
'current_weekday': now_iso[2],
|
||||||
|
'current_week': now_iso[1],
|
||||||
|
'week_number': now_iso[1], # Keep for backwards compatibility
|
||||||
|
'datestamp': now.format(date_format),
|
||||||
|
'timestamp': now.format(time_format),
|
||||||
'unixtime': int(time.time()),
|
'unixtime': int(time.time()),
|
||||||
# Stream parameters
|
# Stream parameters
|
||||||
'streams': stream_count,
|
'streams': stream_count,
|
||||||
|
@ -909,6 +920,9 @@ def build_server_notify_params(notify_action=None, **kwargs):
|
||||||
pms_download_info = defaultdict(str, kwargs.pop('pms_download_info', {}))
|
pms_download_info = defaultdict(str, kwargs.pop('pms_download_info', {}))
|
||||||
plexpy_download_info = defaultdict(str, kwargs.pop('plexpy_download_info', {}))
|
plexpy_download_info = defaultdict(str, kwargs.pop('plexpy_download_info', {}))
|
||||||
|
|
||||||
|
now = arrow.now()
|
||||||
|
now_iso = now.isocalendar()
|
||||||
|
|
||||||
available_params = {
|
available_params = {
|
||||||
# Global paramaters
|
# Global paramaters
|
||||||
'tautulli_version': common.RELEASE,
|
'tautulli_version': common.RELEASE,
|
||||||
|
@ -923,8 +937,17 @@ def build_server_notify_params(notify_action=None, **kwargs):
|
||||||
'server_version': plexpy.CONFIG.PMS_VERSION,
|
'server_version': plexpy.CONFIG.PMS_VERSION,
|
||||||
'server_machine_id': plexpy.CONFIG.PMS_IDENTIFIER,
|
'server_machine_id': plexpy.CONFIG.PMS_IDENTIFIER,
|
||||||
'action': notify_action.split('on_')[-1],
|
'action': notify_action.split('on_')[-1],
|
||||||
'datestamp': arrow.now().format(date_format),
|
'current_year': now.year,
|
||||||
'timestamp': arrow.now().format(time_format),
|
'current_month': now.month,
|
||||||
|
'current_day': now.day,
|
||||||
|
'current_hour': now.hour,
|
||||||
|
'current_minute': now.minute,
|
||||||
|
'current_second': now.second,
|
||||||
|
'current_weekday': now_iso[2],
|
||||||
|
'current_week': now_iso[1],
|
||||||
|
'week_number': now_iso[1], # Keep for backwards compatibility
|
||||||
|
'datestamp': now.format(date_format),
|
||||||
|
'timestamp': now.format(time_format),
|
||||||
'unixtime': int(time.time()),
|
'unixtime': int(time.time()),
|
||||||
# Plex Media Server update parameters
|
# Plex Media Server update parameters
|
||||||
'update_version': pms_download_info['version'],
|
'update_version': pms_download_info['version'],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue