added gridChange variables and TODO comments

This commit is contained in:
pythagoraswitch 2018-07-20 15:59:42 +02:00
parent bb579f2f6f
commit 2eae1aa2a7
2 changed files with 19 additions and 0 deletions

4
.gitignore vendored
View file

@ -1,3 +1,7 @@
json/* json/*
venv/*
__pycache__/ __pycache__/
*.swp *.swp
*.ipynb
*.pyc
test.py

View file

@ -46,6 +46,12 @@ class Engine:
'screenings': {'locked': True, 'value': 2} 'screenings': {'locked': True, 'value': 2}
}, },
'globalKeywords': {}, 'globalKeywords': {},
'gridChange': {
'nextClip': {'locked': False, 'value': 4},
'nextPlaylist': {'locked': False, 'value': 4},
'staySame': {'locked': False, 'value': 8}
}
} }
self.update_keywords() self.update_keywords()
@ -77,9 +83,14 @@ class Engine:
clips[inpoint['index']]['out'] = self.pandora.get(video_id, ['duration'])['duration'] clips[inpoint['index']]['out'] = self.pandora.get(video_id, ['duration'])['duration']
return clips return clips
### TASK 1 ###
# Change this to (1) check if there's no grid event and if so: initialize, and
# (2) if not: add serendipity to the current grid mix using gridChange variables.
def get_videos(self, user): def get_videos(self, 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()}
gridChange = {k: v.get('value', 0) for k, v in self.state['gridChange'].items()}
# For each playlist, compute user keyword score # For each playlist, compute user keyword score
user_keywords = user.get('keywords', {}) user_keywords = user.get('keywords', {})
score = {} score = {}
@ -131,6 +142,10 @@ class Engine:
'tags': video['tags'], 'tags': video['tags'],
} for video in videos] } for video in videos]
### TASK 2 ###
# Change this to make sure the next playlist is not the current playlist
# AND not the playlists displayed in the current grid. Incorporate the change from Task 1.
def get_next(self, user, position): def get_next(self, user, position):
video = self.get_videos(user)[position] video = self.get_videos(user)[position]
return video return video