play_index extraction to incorporate the future data scheme change

This commit is contained in:
pythagoraswitch 2018-07-25 16:13:43 +02:00
parent 83af674af9
commit 71a9effbba

View file

@ -101,6 +101,17 @@ class Engine:
grid_events[event.get('data').get('index')] = event.get('data') grid_events[event.get('data').get('index')] = event.get('data')
if len(grid_events) == video_num: if len(grid_events) == video_num:
break break
# # The version where the loop also extract play_index (requires "index" in play event data):
# play_index = None
# for event in user.get('events', []):
# if event.get('event') == "grid" and event.get('data').get('index') not in grid_events:
# grid_events[event.get('data').get('index')] = event.get('data')
# if event.get('event') == "play" and not play_index:
# play_index = event.get('data').get('index')
# if len(grid_events) == video_num and play_index:
# break
prev_grid_list = sorted([v for v in grid_events.values()], key=lambda k:k['index']) prev_grid_list = sorted([v for v in grid_events.values()], key=lambda k:k['index'])
# if there were no grid events for all, initialize all grids. # if there were no grid events for all, initialize all grids.