mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Add support for commercial marker triggers
This commit is contained in:
parent
32bb98e8c1
commit
6b0b3a476f
5 changed files with 36 additions and 8 deletions
|
@ -656,8 +656,8 @@ def dbcheck():
|
|||
'synced_version INTEGER, synced_version_profile TEXT, '
|
||||
'live INTEGER, live_uuid TEXT, channel_call_sign TEXT, channel_identifier TEXT, channel_thumb TEXT, '
|
||||
'secure INTEGER, relayed INTEGER, '
|
||||
'buffer_count INTEGER DEFAULT 0, buffer_last_triggered INTEGER, last_paused INTEGER, '
|
||||
'watched INTEGER DEFAULT 0, intro INTEGER DEFAULT 0, credits INTEGER DEFAULT 0, marker INTEGER DEFAULT 0, '
|
||||
'buffer_count INTEGER DEFAULT 0, buffer_last_triggered INTEGER, last_paused INTEGER, watched INTEGER DEFAULT 0, '
|
||||
'intro INTEGER DEFAULT 0, credits INTEGER DEFAULT 0, commercial INTEGER DEFAULT 0, marker INTEGER DEFAULT 0, '
|
||||
'initial_stream INTEGER DEFAULT 1, write_attempts INTEGER DEFAULT 0, raw_stream_info TEXT, '
|
||||
'rating_key_websocket TEXT)'
|
||||
)
|
||||
|
@ -1417,6 +1417,15 @@ def dbcheck():
|
|||
'ALTER TABLE sessions ADD COLUMN credits INTEGER DEFAULT 0'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT commercial FROM sessions')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table sessions.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE sessions ADD COLUMN commercial INTEGER DEFAULT 0'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT marker FROM sessions')
|
||||
|
|
|
@ -247,13 +247,20 @@ class ActivityHandler(object):
|
|||
|
||||
def on_intro(self, marker):
|
||||
if self.get_live_session():
|
||||
logger.debug("Tautulli ActivityHandler :: Session %s intro marker reached." % str(self.session_key))
|
||||
logger.debug("Tautulli ActivityHandler :: Session %s reached intro marker." % str(self.session_key))
|
||||
|
||||
self.put_notification('on_intro', marker=marker)
|
||||
|
||||
def on_commercial(self, marker):
|
||||
if self.get_live_session():
|
||||
logger.debug("Tautulli ActivityHandler :: Session %s reached commercial marker." % str(self.session_key))
|
||||
|
||||
self.put_notification('on_commercial', marker=marker)
|
||||
|
||||
def on_credits(self, marker):
|
||||
if self.get_live_session():
|
||||
logger.debug("Tautulli ActivityHandler :: Session %s credits marker reached." % str(self.session_key))
|
||||
logger.debug("Tautulli ActivityHandler :: Session %s reached credits marker." % str(self.session_key))
|
||||
|
||||
self.put_notification('on_credits', marker=marker)
|
||||
|
||||
def on_watched(self):
|
||||
|
|
|
@ -661,8 +661,12 @@ class ActivityProcessor(object):
|
|||
[session['write_attempts'] + 1, session_key])
|
||||
|
||||
def set_marker(self, session_key=None, marker_idx=None, marker_type=None):
|
||||
marker_args = [int(marker_type == 'intro'), int(marker_type == 'credits')]
|
||||
self.db.action('UPDATE sessions SET intro = ?, credits = ?, marker = ? '
|
||||
marker_args = [
|
||||
int(marker_type == 'intro'),
|
||||
int(marker_type == 'commercial'),
|
||||
int(marker_type == 'credits')
|
||||
]
|
||||
self.db.action('UPDATE sessions SET intro = ?, commercial = ?, credits = ?, marker = ? '
|
||||
'WHERE session_key = ?',
|
||||
marker_args + [marker_idx, session_key])
|
||||
|
||||
|
|
|
@ -1023,8 +1023,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
|||
'live': notify_params['live'],
|
||||
'marker_start': marker['start_time_offset'],
|
||||
'marker_end': marker['end_time_offset'],
|
||||
'credits_marker_first': int(marker['first']),
|
||||
'credits_marker_final': int(marker['final']),
|
||||
'credits_marker_first': helpers.cast_to_int(marker['first']),
|
||||
'credits_marker_final': helpers.cast_to_int(marker['final']),
|
||||
'channel_call_sign': notify_params['channel_call_sign'],
|
||||
'channel_identifier': notify_params['channel_identifier'],
|
||||
'channel_thumb': notify_params['channel_thumb'],
|
||||
|
|
|
@ -348,6 +348,14 @@ def available_notification_actions(agent_id=None):
|
|||
'icon': 'fa-bookmark',
|
||||
'media_types': ('episode',)
|
||||
},
|
||||
{'label': 'Commercial Marker',
|
||||
'name': 'on_credits',
|
||||
'description': 'Trigger a notification when a video stream reaches any commercial marker.',
|
||||
'subject': 'Tautulli ({server_name})',
|
||||
'body': '{user} ({player}) has reached a commercial marker for {title}.',
|
||||
'icon': 'fa-bookmark',
|
||||
'media_types': ('movie', 'episode')
|
||||
},
|
||||
{'label': 'Credits Marker',
|
||||
'name': 'on_credits',
|
||||
'description': 'Trigger a notification when a video stream reaches any credits marker.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue