def process(opcode, data): if opcode not in opcode_data: return False try: data = data.decode('utf-8') logger.websocket_debug(data) event = json.loads(data) except Exception as e: logger.warn("Tautulli WebSocket :: Error decoding message from websocket: %s" % e) logger.websocket_error(data) return False event = event.get('NotificationContainer', event) event_type = event.get('type') if not event_type: return False if event_type == 'playing': event_data = event.get('PlaySessionStateNotification', event.get('_children', {})) if not event_data: logger.debug("Tautulli WebSocket :: Session event found but unable to get websocket data.") return False try: activity = activity_handler.ActivityHandler(timeline=event_data[0]) activity.process() except Exception as e: logger.exception("Tautulli WebSocket :: Failed to process session data: %s." % e) if event_type == 'timeline': event_data = event.get('TimelineEntry', event.get('_children', {})) if not event_data: logger.debug("Tautulli WebSocket :: Timeline event found but unable to get websocket data.") return False try: activity = activity_handler.TimelineHandler(timeline=event_data[0]) activity.process() except Exception as e: logger.exception("Tautulli WebSocket :: Failed to process timeline data: %s." % e) if event_type == 'reachability': event_data = event.get('ReachabilityNotification', event.get('_children', {})) if not event_data: logger.debug("Tautulli WebSocket :: Reachability event found but unable to get websocket data.") return False try: activity = activity_handler.ReachabilityHandler(data=event_data[0]) activity.process() except Exception as e: logger.exception("Tautulli WebSocket :: Failed to process reachability data: %s." % e) return True
def process(opcode, data): if opcode not in opcode_data: return False try: logger.websocket_debug(data) info = json.loads(data) except Exception as e: logger.warn( u"Tautulli WebSocket :: Error decoding message from websocket: %s" % e) logger.websocket_error(data) return False info = info.get('NotificationContainer', info) type = info.get('type') if not type: return False if type == 'playing': time_line = info.get('PlaySessionStateNotification', info.get('_children', {})) if not time_line: logger.debug( u"Tautulli WebSocket :: Session found but unable to get timeline data." ) return False try: activity = activity_handler.ActivityHandler(timeline=time_line[0]) activity.process() except Exception as e: logger.error( u"Tautulli WebSocket :: Failed to process session data: %s." % e) if type == 'timeline': time_line = info.get('TimelineEntry', info.get('_children', {})) if not time_line: logger.debug( u"Tautulli WebSocket :: Timeline event found but unable to get timeline data." ) return False try: activity = activity_handler.TimelineHandler(timeline=time_line[0]) activity.process() except Exception as e: logger.error( u"Tautulli WebSocket :: Failed to process timeline data: %s." % e) return True
def process(opcode, data): if opcode not in opcode_data: return False try: info = json.loads(data) except Exception as e: logger.warn( u"PlexPy WebSocket :: Error decoding message from websocket: %s" % e) logger.debug(data) return False info = info.get('NotificationContainer', info) type = info.get('type') if not type: return False if type == 'playing': # logger.debug('%s.playing %s' % (name, info)) time_line = info.get('PlaySessionStateNotification', info.get('_children')) if not time_line: logger.debug( u"PlexPy WebSocket :: Session found but unable to get timeline data." ) return False activity = activity_handler.ActivityHandler(timeline=time_line[0]) activity.process() #if type == 'timeline': # try: # time_line = info.get('_children') # except: # logger.debug(u"PlexPy WebSocket :: Timeline event found but unable to get timeline data.") # return False # activity = activity_handler.TimelineHandler(timeline=time_line[0]) # activity.process() return True