only change return signature of get_videos
This commit is contained in:
parent
0fe5752db3
commit
4bd4af703e
1 changed files with 14 additions and 10 deletions
|
@ -88,7 +88,12 @@ class Engine:
|
|||
def get_videos(self, user):
|
||||
|
||||
if user.get('events', [{}])[0].get("event")=="login":
|
||||
return self.get_recommendations(user)
|
||||
return {
|
||||
'user': {
|
||||
'keywords': user.get('keywords', {})
|
||||
},
|
||||
'videos': self.get_recommendations(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()}
|
||||
|
@ -121,7 +126,12 @@ class Engine:
|
|||
|
||||
# if there were no grid events for all, initialize all grids.
|
||||
if len(prev_grid_list) < video_num:
|
||||
return self.get_recommendations(user)
|
||||
return {
|
||||
'user': {
|
||||
'keywords': user.get('keywords', {})
|
||||
},
|
||||
'videos': self.get_recommendations(user)
|
||||
}
|
||||
|
||||
else:
|
||||
if play_index is None:
|
||||
|
@ -245,18 +255,12 @@ class Engine:
|
|||
)[:16 - channels['userKeywords'] - channels['globalKeywords']]
|
||||
# Shuffle playlists (randomize layout) and shift clips (randomize start)
|
||||
random.shuffle(videos)
|
||||
videos_ = [{
|
||||
return [{
|
||||
'clips': video['clips'],
|
||||
'position': random.randrange(len(video['clips'])),
|
||||
'name': video['name'],
|
||||
'tags': video['tags'],
|
||||
} for video in videos]
|
||||
return {
|
||||
'user': {
|
||||
'keywords': user.get('keywords', {})
|
||||
},
|
||||
'videos': videos_
|
||||
}
|
||||
|
||||
|
||||
def get_next(self, user, position):
|
||||
|
|
Loading…
Reference in a new issue