def parse_episode_action(action, user, update_urls, now, ua_string): action_str = action.get('action', None) if not valid_episodeaction(action_str): raise Exception('invalid action %s' % action_str) history = EpisodeHistoryEntry() history.action = action['action'] if action.get('device', False): client = get_device(user, action['device'], ua_string) history.client = client if action.get('timestamp', False): history.timestamp = dateutil.parser.parse(action['timestamp']) else: history.timestamp = now history.started = action.get('started', None) history.stopped = action.get('position', None) history.total = action.get('total', None) return history
def parse_episode_action(action, user, update_urls, now, ua_string): action_str = action.get("action", None) if not valid_episodeaction(action_str): raise Exception("invalid action %s" % action_str) history = EpisodeHistoryEntry() history.action = action["action"] if action.get("device", False): client = get_device(user, action["device"], ua_string) history.client = client if action.get("timestamp", False): history.timestamp = dateutil.parser.parse(action["timestamp"]) else: history.timestamp = now history.started = action.get("started", None) history.stopped = action.get("position", None) history.total = action.get("total", None) return history