Rename continued session to initial stream

This commit is contained in:
JonnyWong16 2020-04-23 23:03:20 -07:00
parent 4ece976dc8
commit 22bc0b3f9a
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 13 additions and 13 deletions

View file

@ -976,7 +976,7 @@
<p class="help-block">
The number of seconds between stopping and starting a new stream to be considered as a continued session. Set to 0 to consider all streams as new sessions.
<br>
Note: The threshold is only used for the continued session notification parameter.
Note: The threshold is only used by the "Initial Stream" notification parameter to determine if a stream is the first stream of a continuous streaming session.
</p>
</div>

View file

@ -610,7 +610,7 @@ def dbcheck():
'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, '
'continued_session INTEGER DEFAULT 0, write_attempts INTEGER DEFAULT 0, raw_stream_info TEXT)'
'initial_stream INTEGER DEFAULT 1, write_attempts INTEGER DEFAULT 0, raw_stream_info TEXT)'
)
# sessions_continued table :: This is a temp table that keeps track of continued streaming sessions
@ -1284,11 +1284,11 @@ def dbcheck():
# Upgrade sessions table from earlier versions
try:
c_db.execute('SELECT continued_session FROM sessions')
c_db.execute('SELECT initial_stream FROM sessions')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table sessions.")
c_db.execute(
'ALTER TABLE sessions ADD COLUMN continued_session INTEGER DEFAULT 0'
'ALTER TABLE sessions ADD COLUMN initial_stream INTEGER DEFAULT 1'
)
# Upgrade session_history table from earlier versions

View file

@ -144,11 +144,11 @@ class ActivityProcessor(object):
if result == 'insert':
# If it's our first write then time stamp it.
started = int(time.time())
continued_session = self.is_continued_session(user_id=values['user_id'],
machine_id=values['machine_id'],
media_type=values['media_type'],
started=started)
timestamp = {'started': started, 'continued_session': continued_session}
initial_stream = self.is_initial_stream(user_id=values['user_id'],
machine_id=values['machine_id'],
media_type=values['media_type'],
started=started)
timestamp = {'started': started, 'initial_stream': initial_stream}
self.db.upsert('sessions', timestamp, keys)
# Check if any notification agents have notifications enabled
@ -647,10 +647,10 @@ class ActivityProcessor(object):
values = {'stopped': stopped}
self.db.upsert(table_name='sessions_continued', key_dict=keys, value_dict=values)
def is_continued_session(self, user_id=None, machine_id=None, media_type=None, started=None):
def is_initial_stream(self, user_id=None, machine_id=None, media_type=None, started=None):
last_session = self.db.select_single('SELECT stopped '
'FROM sessions_continued '
'WHERE user_id = ? AND machine_id = ? AND media_type = ? '
'ORDER BY stopped DESC',
[user_id, machine_id, media_type])
return int(started - last_session.get('stopped', 0) < plexpy.CONFIG.NOTIFY_CONTINUED_SESSION_THRESHOLD)
return int(started - last_session.get('stopped', 0) > plexpy.CONFIG.NOTIFY_CONTINUED_SESSION_THRESHOLD)

View file

@ -359,6 +359,7 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Platform', 'type': 'str', 'value': 'platform', 'description': 'The type of client platform being used for playback.'},
{'name': 'Product', 'type': 'str', 'value': 'product', 'description': 'The type of client product being used for playback.'},
{'name': 'Player', 'type': 'str', 'value': 'player', 'description': 'The name of the player being used for playback.'},
{'name': 'Initial Stream', 'type': 'int', 'value': 'initial_stream', 'description': 'If the stream is the initial stream of a continuous streaming session.', 'example': '0 or 1'},
{'name': 'IP Address', 'type': 'str', 'value': 'ip_address', 'description': 'The IP address of the device being used for playback.'},
{'name': 'Stream Duration', 'type': 'int', 'value': 'stream_duration', 'description': 'The duration (in minutes) for the stream.'},
{'name': 'Stream Time', 'type': 'str', 'value': 'stream_time', 'description': 'The duration (in time format) of the stream.'},
@ -367,7 +368,6 @@ NOTIFICATION_PARAMETERS = [
{'name': 'Progress Duration', 'type': 'int', 'value': 'progress_duration', 'description': 'The last reported offset (in minutes) of the stream.'},
{'name': 'Progress Time', 'type': 'str', 'value': 'progress_time', 'description': 'The last reported offset (in time format) of the stream.'},
{'name': 'Progress Percent', 'type': 'int', 'value': 'progress_percent', 'description': 'The last reported progress percent of the stream.'},
{'name': 'Continued Session', 'type': 'int', 'value': 'continued_session', 'description': 'If the stream is continued from the previous streaming session.', 'example': '0 or 1'},
{'name': 'Transcode Decision', 'type': 'str', 'value': 'transcode_decision', 'description': 'The transcode decisions of the stream.'},
{'name': 'Video Decision', 'type': 'str', 'value': 'video_decision', 'description': 'The video transcode decisions of the stream.'},
{'name': 'Audio Decision', 'type': 'str', 'value': 'audio_decision', 'description': 'The audio transcode decisions of the stream.'},

View file

@ -843,7 +843,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
'progress_duration': view_offset,
'progress_time': arrow.get(view_offset * 60).format(duration_format),
'progress_percent': helpers.get_percent(view_offset, duration),
'continued_session': notify_params['continued_session'],
'initial_stream': notify_params['initial_stream'],
'transcode_decision': transcode_decision,
'video_decision': notify_params['video_decision'],
'audio_decision': notify_params['audio_decision'],