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):
|
def get_videos(self, user):
|
||||||
|
|
||||||
if user.get('events', [{}])[0].get("event")=="login":
|
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()}
|
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()}
|
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 there were no grid events for all, initialize all grids.
|
||||||
if len(prev_grid_list) < video_num:
|
if len(prev_grid_list) < video_num:
|
||||||
return self.get_recommendations(user)
|
return {
|
||||||
|
'user': {
|
||||||
|
'keywords': user.get('keywords', {})
|
||||||
|
},
|
||||||
|
'videos': self.get_recommendations(user)
|
||||||
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if play_index is None:
|
if play_index is None:
|
||||||
|
@ -245,18 +255,12 @@ class Engine:
|
||||||
)[:16 - channels['userKeywords'] - channels['globalKeywords']]
|
)[:16 - channels['userKeywords'] - channels['globalKeywords']]
|
||||||
# Shuffle playlists (randomize layout) and shift clips (randomize start)
|
# Shuffle playlists (randomize layout) and shift clips (randomize start)
|
||||||
random.shuffle(videos)
|
random.shuffle(videos)
|
||||||
videos_ = [{
|
return [{
|
||||||
'clips': video['clips'],
|
'clips': video['clips'],
|
||||||
'position': random.randrange(len(video['clips'])),
|
'position': random.randrange(len(video['clips'])),
|
||||||
'name': video['name'],
|
'name': video['name'],
|
||||||
'tags': video['tags'],
|
'tags': video['tags'],
|
||||||
} for video in videos]
|
} for video in videos]
|
||||||
return {
|
|
||||||
'user': {
|
|
||||||
'keywords': user.get('keywords', {})
|
|
||||||
},
|
|
||||||
'videos': videos_
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def get_next(self, user, position):
|
def get_next(self, user, position):
|
||||||
|
|
Loading…
Reference in a new issue