Adds ip_addres to notification options

This is iffy because the IP address is unknown when state == 'play',
which is when it's the most useful.
This commit is contained in:
Jonathan Wong 2015-08-23 15:06:16 -07:00
commit 4b34490800
2 changed files with 15 additions and 6 deletions

View file

@ -766,13 +766,17 @@ available_notification_agents = notifiers.available_notification_agents()
</p>
<table>
<tbody>
<tr>
<td width="150"><strong>{server_name}</strong></td>
<td>The name of your Plex Server.</td>
</tr>
<tr>
<td width="150"><strong>{user}</strong></td>
<td>The username of the person streaming.</td>
</tr>
<tr>
<td width="150"><strong>{server_name}</strong></td>
<td>The name of your Plex Server.</td>
<td width="150"><strong>{ip_address}</strong></td>
<td>The IP address of the person streaming.</td>
</tr>
<tr>
<td width="150"><strong>{player}</strong></td>
@ -782,6 +786,10 @@ available_notification_agents = notifiers.available_notification_agents()
<td width="150"><strong>{platform}</strong></td>
<td>The type of client being used for playback.</td>
</tr>
<tr>
<td width="150"><strong>{transcode_decision}</strong></td>
<td>The transcode decisions for the media item.</td>
</tr>
<tr>
<td width="150"><strong>{title}</strong></td>
<td>The title of the item being played back.</td>
@ -798,10 +806,6 @@ available_notification_agents = notifiers.available_notification_agents()
<td width="150"><strong>{album_name}</strong></td>
<td>The title of the album being played back if item is track.</td>
</tr>
<tr>
<td width="150"><strong>{transcode_decision}</strong></td>
<td>The transcode decisions for the media item.</td>
</tr>
<tr>
<td width="150"><strong>{year}</strong></td>
<td>The release year for the media item.</td>

View file

@ -303,8 +303,12 @@ def build_notify_text(session, state):
duration = helpers.convert_milliseconds_to_minutes(item_metadata['duration'])
view_offset = helpers.convert_milliseconds_to_minutes(session['view_offset'])
ip_address = 'IP unknown'
stream_duration = 0
if state != 'play':
if session['ip_address'].index('.') > -1:
ip_address = session['ip_address']
if session['paused_counter']:
stream_duration = int((time.time() - helpers.cast_to_float(session['started']) -
helpers.cast_to_float(session['paused_counter'])) / 60)
@ -315,6 +319,7 @@ def build_notify_text(session, state):
available_params = {'server_name': server_name,
'user': session['friendly_name'],
'ip_address': ip_address,
'player': session['player'],
'title': full_title,
'show_name': item_metadata['grandparent_title'],