diff --git a/recommendation_engine.py b/recommendation_engine.py index 207a03f..17b9372 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -127,7 +127,8 @@ class Engine: return [{ 'clips': video['clips'], 'position': random.randrange(len(video['clips'])), - 'name': video['name'] + 'name': video['name'], + 'tags': video['tags'], } for video in videos] def update_state(self, data): @@ -210,15 +211,20 @@ class Engine: if 'globalKeywords' not in self.state: self.state['globalKeywords'] = {} changed = True + existing_tags = set() for playlist in self.playlists: for tag in playlist.get('tags', []): + if not tag.isupper() and tag: + existing_tags.add(tag) if not tag.isupper() and tag not in self.state['globalKeywords']: self.state['globalKeywords'][tag] = {'value': 0} changed = True + for tag in set(self.state['globalKeywords']) - existing_tags: + del self.state['globalKeywords'][tag] + changed = True if changed: self.save_state() - @run_async def update_async(self): self.update()