def get_browse_playlist_and_vote_on_song(self): emotion = random.choice(self.emotions) resp = MoodyTunesClient.get_browse_playlist(self.client, emotion) resp_data = resp.json() if resp_data['results']: song = random.choice(resp_data['results']) vote = random.choice([True, False]) # Randomize value for vote MoodyTunesClient.create_vote(self.client, song, emotion, vote, self.host)
def delete_song_from_emotion_playlist(self): resp = MoodyTunesClient.get_emotion_playlist(self.client, self.emotion) resp_data = resp.json() # If there are songs in the playlist, delete a song from it if resp_data['results']: votes = resp_data['results'] song = random.choice(votes)['song'] MoodyTunesClient.delete_vote(self.client, song, self.emotion, self.host) # Otherwise, create a new playlist for the emotion else: self.create_playlist()
def create_playlist(self): self.emotion = random.choice(self.emotions) # Get songs for the browse playlist for emotion to vote on resp = MoodyTunesClient.get_browse_playlist(self.client, self.emotion) resp_data = resp.json() csrf_token = MoodyTunesClient.get_csrf_token(self.client, '/moodytunes/browse/') for song in resp_data['results']: MoodyTunesClient.create_vote(self.client, song, self.emotion, True, self.host, csrf_token=csrf_token)
def get_last_playlist(self): MoodyTunesClient.get_last_playlist(self.client)
def create_user(self): return MoodyTunesClient.create_user(self.client, self.host)
def login(self, username, password): return MoodyTunesClient.login(self.client, username, password, self.host)
def get_emotion_playlist(self): MoodyTunesClient.get_emotion_playlist(self.client, self.emotion)