This commit is contained in:
j 2018-05-19 13:51:02 +02:00
parent a0f3f411c3
commit 5212e46563
2 changed files with 8 additions and 1 deletions

View file

@ -78,6 +78,7 @@ class Engine:
return clips
def get_videos(self, user):
user = kwargs['user']
channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()}
sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()}
# For each playlist, compute user keyword score
@ -131,6 +132,10 @@ class Engine:
'tags': video['tags'],
} for video in videos]
def get_next(self, user, position):
video = self.get_videos(user)[position]
return video
def update_state(self, data):
for key in data:
if key in self.state:

View file

@ -27,7 +27,9 @@ logger = logging.getLogger(__name__)
def api_task(request, engine, callback):
try:
if request['method'] == 'getVideos':
result = engine.get_videos(request['params'])
result = engine.get_videos(**request['params'])
elif request['method'] == 'getNext':
result = engine.get_next(**request['params'])
elif request['method'] == 'getRecommendations':
result = engine.state
elif request['method'] == 'setRecommendations':