Compare commits

...

18 Commits

Author SHA1 Message Date
Jonathan Wong
81b22a8c36 Merge branch 'dev' 2015-11-27 06:38:31 -08:00
Jonathan Wong
beb66396fe v1.2.7 2015-11-27 06:33:03 -08:00
Jonathan Wong
aaf3de68cf Fix IP address in notifications 2015-11-27 06:29:41 -08:00
Jonathan Wong
c827c9e825 Fix IP logging again
* Really this time...
2015-11-27 12:33:34 +02:00
Tim van der Westhuizen
5100fdbc96 Merge branch 'dev' 2015-11-27 10:53:28 +02:00
Tim van der Westhuizen
fae3f38a88 v1.2.6 2015-11-27 10:52:29 +02:00
Tim van der Westhuizen
a8236222fb Catch null ratingKeys in plexWatch db importer.
Make sure we have a string when parsing the latinToAscii function.
2015-11-27 10:45:25 +02:00
Jonathan Wong
2be4d9b6c9 Merge branch 'dev' 2015-11-26 19:08:46 -08:00
Jonathan Wong
00934b04d2 Fix IP logging again
* Really this time...
2015-11-26 19:06:51 -08:00
Jonathan Wong
1e28b22c70 Merge branch 'dev' 2015-11-25 20:23:44 -08:00
Jonathan Wong
776061605f Fix IP logging again 2015-11-25 20:20:06 -08:00
Jonathan Wong
683e5663e1 Merge branch 'dev' 2015-11-25 19:16:50 -08:00
Jonathan Wong
090011c9a5 v1.2.5 2015-11-25 19:15:40 -08:00
Jonathan Wong
30b11bce98 Actually add video and audio decision to notifications 2015-11-25 19:13:08 -08:00
Jonathan Wong
2a91ec1560 Fix season and episode number notification option return at least one digit 2015-11-25 19:07:23 -08:00
Jonathan Wong
908ce1ff8d Fix IP address logging 2015-11-25 19:02:59 -08:00
Jonathan Wong
fac47ee68b Fix log spam if notifications turned off 2015-11-25 18:14:08 -08:00
Jonathan Wong
0f8c122ee3 Add video and audio decision to notification options 2015-11-25 18:12:20 -08:00
7 changed files with 69 additions and 33 deletions

View File

@@ -1,5 +1,22 @@
# Changelog # Changelog
## v1.2.7 (2015-11-27)
* Fix IP address option in notifications
## v1.2.6 (2015-11-27)
* Fixes for IP logging in PMS < 0.9.14.x.
* Fix issue in plexWatch importer when trying to import item with no ratingKey.
## v1.2.5 (2015-11-25)
* Add video_decision and audio_decision to notification options
* Fix IP address logging
* Fix log spam if notifications disabled
## v1.2.4 (2015-11-24) ## v1.2.4 (2015-11-24)
* Add filtering by media type in the history table * Add filtering by media type in the history table

View File

@@ -1001,9 +1001,17 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<td width="150"><strong>{episode_num00}</strong></td> <td width="150"><strong>{episode_num00}</strong></td>
<td>The two digit episode number.</td> <td>The two digit episode number.</td>
</tr> </tr>
<tr>
<td width="150"><strong>{video_decision}</strong></td>
<td>The video transcode decisions for the media item.</td>
</tr>
<tr>
<td width="150"><strong>{audio_decision}</strong></td>
<td>The audio transcode decisions for the media item.</td>
</tr>
<tr> <tr>
<td width="150"><strong>{transcode_decision}</strong></td> <td width="150"><strong>{transcode_decision}</strong></td>
<td>The transcode decisions for the media item.</td> <td>The stream transcode decisions for the media item.</td>
</tr> </tr>
<tr> <tr>
<td width="150"><strong>{year}</strong></td> <td width="150"><strong>{year}</strong></td>

View File

@@ -39,7 +39,7 @@ class ActivityProcessor(object):
'parent_title': session['parent_title'], 'parent_title': session['parent_title'],
'grandparent_title': session['grandparent_title'], 'grandparent_title': session['grandparent_title'],
'friendly_name': session['friendly_name'], 'friendly_name': session['friendly_name'],
'ip_address': session['ip_address'], #'ip_address': session['ip_address'],
'player': session['player'], 'player': session['player'],
'platform': session['platform'], 'platform': session['platform'],
'parent_rating_key': session['parent_rating_key'], 'parent_rating_key': session['parent_rating_key'],
@@ -67,6 +67,10 @@ class ActivityProcessor(object):
'transcode_height': session['transcode_height'] 'transcode_height': session['transcode_height']
} }
# Add ip_address back into values
if session['ip_address']:
values.update({'ip_address': session['ip_address']})
keys = {'session_key': session['session_key'], keys = {'session_key': session['session_key'],
'rating_key': session['rating_key']} 'rating_key': session['rating_key']}
@@ -75,23 +79,22 @@ class ActivityProcessor(object):
if result == 'insert': if result == 'insert':
# Push any notifications - Push it on it's own thread so we don't hold up our db actions # Push any notifications - Push it on it's own thread so we don't hold up our db actions
if notify: if notify:
values.update({'ip_address': session['ip_address']})
threading.Thread(target=notification_handler.notify, threading.Thread(target=notification_handler.notify,
kwargs=dict(stream_data=values, notify_action='play')).start() kwargs=dict(stream_data=values, notify_action='play')).start()
# If it's our first write then time stamp it.
started = int(time.time()) started = int(time.time())
timestamp = {'started': started} timestamp = {'started': started}
self.db.upsert('sessions', timestamp, keys)
# Try and grab IP address from logs (fallback if not on PMS 0.9.14 and above) # Try and grab IP address from logs (fallback if not on PMS 0.9.14 and above)
if not session['ip_address']: if not session['ip_address']:
if plexpy.CONFIG.IP_LOGGING_ENABLE and plexpy.CONFIG.PMS_LOGS_FOLDER: if plexpy.CONFIG.IP_LOGGING_ENABLE and plexpy.CONFIG.PMS_LOGS_FOLDER:
ip_address = self.find_session_ip(rating_key=session['rating_key'], ip_address = self.find_session_ip(rating_key=session['rating_key'],
machine_id=session['machine_id']) machine_id=session['machine_id'])
timestamp.update({'ip_address': ip_address}) ip_address = {'ip_address': ip_address}
else: self.db.upsert('sessions', ip_address, keys)
timestamp.update({'ip_address': None})
# If it's our first write then time stamp it.
self.db.upsert('sessions', timestamp, keys)
def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0): def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0):
from plexpy import users from plexpy import users

View File

@@ -92,13 +92,15 @@ def latinToAscii(unicrap):
} }
r = '' r = ''
for i in unicrap: if unicrap:
if ord(i) in xlate: for i in unicrap:
r += xlate[ord(i)] if ord(i) in xlate:
elif ord(i) >= 0x80: r += xlate[ord(i)]
pass elif ord(i) >= 0x80:
else: pass
r += str(i) else:
r += str(i)
return r return r

View File

@@ -161,7 +161,7 @@ def notify(stream_data=None, notify_action=None):
elif stream_data['media_type'] == 'clip': elif stream_data['media_type'] == 'clip':
pass pass
else: else:
logger.debug(u"PlexPy Notifier :: Notify called with unsupported media type.") #logger.debug(u"PlexPy Notifier :: Notify called with unsupported media type.")
pass pass
else: else:
logger.debug(u"PlexPy Notifier :: Notify called but incomplete data received.") logger.debug(u"PlexPy Notifier :: Notify called but incomplete data received.")
@@ -370,6 +370,8 @@ def build_notify_text(session=None, timeline=None, state=None):
duration = helpers.convert_milliseconds_to_minutes(metadata['duration']) duration = helpers.convert_milliseconds_to_minutes(metadata['duration'])
# Default values # Default values
video_decision = ''
audio_decision = ''
transcode_decision = '' transcode_decision = ''
stream_duration = 0 stream_duration = 0
view_offset = 0 view_offset = 0
@@ -381,18 +383,15 @@ def build_notify_text(session=None, timeline=None, state=None):
# Session values # Session values
if session: if session:
# Generate a combined transcode decision value # Generate a combined transcode decision value
if session['video_decision']: video_decision = session['video_decision'].title()
if session['video_decision'] == 'transcode': audio_decision = session['audio_decision'].title()
transcode_decision = 'Transcode'
elif session['video_decision'] == 'copy' or session['audio_decision'] == 'copy': if session['video_decision'] == 'transcode' or session['audio_decision'] == 'transcode':
transcode_decision = 'Direct Stream' transcode_decision = 'Transcode'
else: elif session['video_decision'] == 'copy' or session['audio_decision'] == 'copy':
transcode_decision = 'Direct Play' transcode_decision = 'Direct Stream'
elif session['audio_decision']: else:
if session['audio_decision'] == 'transcode': transcode_decision = 'Direct Play'
transcode_decision = 'Transcode'
else:
transcode_decision = 'Direct Play'
if state != 'play': if state != 'play':
if session['paused_counter']: if session['paused_counter']:
@@ -405,7 +404,7 @@ def build_notify_text(session=None, timeline=None, state=None):
user = session['friendly_name'] user = session['friendly_name']
platform = session['platform'] platform = session['platform']
player = session['player'] player = session['player']
ip_address = session['ip_address'] if session['ip_address'] != '' else 'N/A' ip_address = session['ip_address'] if session['ip_address'] else 'N/A'
progress_percent = helpers.get_percent(view_offset, duration) progress_percent = helpers.get_percent(view_offset, duration)
@@ -422,10 +421,12 @@ def build_notify_text(session=None, timeline=None, state=None):
'artist_name': metadata['grandparent_title'], 'artist_name': metadata['grandparent_title'],
'album_name': metadata['parent_title'], 'album_name': metadata['parent_title'],
'track_name': metadata['title'], 'track_name': metadata['title'],
'season_num': metadata['parent_index'], 'season_num': metadata['parent_index'].zfill(1),
'season_num00': metadata['parent_index'].zfill(2), 'season_num00': metadata['parent_index'].zfill(2),
'episode_num': metadata['index'], 'episode_num': metadata['index'].zfill(1),
'episode_num00': metadata['index'].zfill(2), 'episode_num00': metadata['index'].zfill(2),
'video_decision': video_decision,
'audio_decision': audio_decision,
'transcode_decision': transcode_decision, 'transcode_decision': transcode_decision,
'year': metadata['year'], 'year': metadata['year'],
'studio': metadata['studio'], 'studio': metadata['studio'],

View File

@@ -292,10 +292,15 @@ def import_from_plexwatch(database=None, table_name=None, import_ignore_interval
# If we get back None from our xml extractor skip over the record and log error. # If we get back None from our xml extractor skip over the record and log error.
if not extracted_xml: if not extracted_xml:
logger.error(u"PlexPy Importer :: Skipping line with ratingKey %s due to malformed xml." logger.error(u"PlexPy Importer :: Skipping record with ratingKey %s due to malformed xml."
% str(row['rating_key'])) % str(row['rating_key']))
continue continue
# Skip line if we don't have a ratingKey to work with
if not row['rating_key']:
logger.error(u"PlexPy Importer :: Skipping record due to null ratingRey.")
continue
# If the user_id no longer exists in the friends list, pull it from the xml. # If the user_id no longer exists in the friends list, pull it from the xml.
if user_data.get_user_id(user=row['user']): if user_data.get_user_id(user=row['user']):
user_id = user_data.get_user_id(user=row['user']) user_id = user_data.get_user_id(user=row['user'])

View File

@@ -1,2 +1,2 @@
PLEXPY_VERSION = "master" PLEXPY_VERSION = "master"
PLEXPY_RELEASE_VERSION = "1.2.4" PLEXPY_RELEASE_VERSION = "1.2.7"