mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Switch recently added to only use activity pinger
* Fixed activity pinger logic for grouping notifications
This commit is contained in:
parent
53044c75dd
commit
69a3b5134f
5 changed files with 56 additions and 50 deletions
|
@ -167,7 +167,10 @@ def check_active_sessions(ws_request=False):
|
|||
def check_recently_added():
|
||||
|
||||
with monitor_lock:
|
||||
current_time = int(time.time())
|
||||
# add delay to allow for metadata processing
|
||||
delay = plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY
|
||||
time_threshold = int(time.time()) - delay
|
||||
time_interval = plexpy.CONFIG.MONITORING_INTERVAL
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
recently_added_list = pms_connect.get_recently_added_details(count='10')
|
||||
|
@ -176,36 +179,43 @@ def check_recently_added():
|
|||
recently_added = recently_added_list['recently_added']
|
||||
|
||||
for item in recently_added:
|
||||
if int(item['added_at']) >= current_time - plexpy.CONFIG.MONITORING_INTERVAL:
|
||||
if item['media_type'] == 'movie':
|
||||
metadata_list = pms_connect.get_metadata_details(item['rating_key'])
|
||||
if metadata_list:
|
||||
metadata = [metadata_list['metadata']]
|
||||
else:
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve metadata for rating_key %s" % str(item['rating_key']))
|
||||
|
||||
elif plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT:
|
||||
metadata_list = pms_connect.get_metadata_details(item['parent_rating_key'])
|
||||
if metadata_list:
|
||||
metadata = [metadata_list['metadata']]
|
||||
else:
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve metadata for parent_rating_key %s" % str(item['parent_rating_key']))
|
||||
|
||||
if item['media_type'] == 'movie':
|
||||
metadata_list = pms_connect.get_metadata_details(item['rating_key'])
|
||||
if metadata_list:
|
||||
metadata = [metadata_list['metadata']]
|
||||
else:
|
||||
metadata_list = pms_connect.get_metadata_children_details(item['rating_key'])
|
||||
if metadata_list:
|
||||
metadata = metadata_list['metadata']
|
||||
else:
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve children metadata for rating_key" % str(item['rating_key']))
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve metadata for rating_key %s" \
|
||||
% str(item['rating_key']))
|
||||
|
||||
if metadata:
|
||||
else:
|
||||
metadata_list = pms_connect.get_metadata_children_details(item['rating_key'])
|
||||
if metadata_list:
|
||||
metadata = metadata_list['metadata']
|
||||
else:
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve children metadata for rating_key %s" \
|
||||
% str(item['rating_key']))
|
||||
|
||||
if metadata:
|
||||
if not plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT:
|
||||
for item in metadata:
|
||||
if (plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT \
|
||||
and int(item['updated_at']) >= current_time - plexpy.CONFIG.MONITORING_INTERVAL) \
|
||||
or (not plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT \
|
||||
and int(item['added_at']) >= current_time - plexpy.CONFIG.MONITORING_INTERVAL):
|
||||
logger.debug(u"PlexPy Monitor :: Library item %s has been added to Plex." % str(item['rating_key']))
|
||||
|
||||
if 0 < int(item['added_at']) - time_threshold <= time_interval:
|
||||
# Fire off notifications
|
||||
threading.Thread(target=notification_handler.notify_timeline,
|
||||
kwargs=dict(timeline_data=item, notify_action='created')).start()
|
||||
|
||||
else:
|
||||
item = max(metadata, key=lambda x:x['added_at'])
|
||||
|
||||
if 0 < int(item['added_at']) - time_threshold <= time_interval:
|
||||
if item['media_type'] == 'episode' or item['media_type'] == 'track':
|
||||
metadata_list = pms_connect.get_metadata_details(item['grandparent_rating_key'])
|
||||
|
||||
if metadata_list:
|
||||
item = metadata_list['metadata']
|
||||
else:
|
||||
logger.error(u"PlexPy Monitor :: Unable to retrieve grandparent metadata for grandparent_rating_key %s" \
|
||||
% str(item['rating_key']))
|
||||
|
||||
# Fire off notifications
|
||||
threading.Thread(target=notification_handler.notify_timeline,
|
||||
kwargs=dict(timeline_data=item, notify_action='created')).start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue