def currently_playing(self): song = self.is_playing() if not song: return "" else: return "**Currently Playing** " + self.format_song(extract_song_data(song)) + "\n"
def queue(self, title): """ Queues a song up by the title, with an optional index in the case of multiple results for a title. Args: title (string): {song_title}, (optional) {index} Returns: response_msg (string): response status message of whether song was queued. """ song_info = title.split(",") if len(song_info) > 1: try: index = max(int(song_info[1].strip()) - 1, 0) except ValueError: index = 0 else: index = 0 search = song_info[0].strip() song = self.music_client.find(search=search, index=index) if isinstance(song, Song): self.music_data.queue(song, queued_by=self.command_user) song = extract_song_data(song) song['queued_by'] = self.command_user response_msg = "Queued: " + self.format_song(song) else: response_msg = "Unable to queue, song not found" return response_msg
def currently_playing(self): song = self.is_playing() if not song: return "" else: return "**Currently Playing** " + self.format_song( extract_song_data(song)) + "\n"
def radio(self, genre=None, prefetch=1): if not genre: genre = Radio.GENRE_METAL # Metal default, because its the best |M| music_collection = [] try: for index, song in enumerate(self.music_client.radio(genre), start=1): music_collection.append(extract_song_data(song)) if index == prefetch: break except Exception as e: music_collection = [] return music_collection
def set_currently_playing(self, song=None): if isinstance(song, dict): print "Setting server status to playing" return self.storage.use_collection('server_stats').update( {}, { '$set': { 'currently_playing': extract_song_data(song), 'status': 'playing' } }, upsert=False) else: print "Server polling..." return self.storage.use_collection('server_stats').update( {}, {'$set': { 'currently_playing': {}, 'status': 'polling' }}, upsert=True)
def set_currently_playing(self, song=None): if isinstance(song, dict): print "Setting server status to playing" return self.storage.use_collection('server_stats').update({}, {'$set': {'currently_playing': extract_song_data(song), 'status': 'playing'}}, upsert=False) else: print "Server polling..." return self.storage.use_collection('server_stats').update({}, {'$set': {'currently_playing': {}, 'status': 'polling'}}, upsert=True)
def search_grooveshark_songs(): term = request.get_json().get("search") songs = g.client.find(search=term, max_results=10) if songs: resp = response(messages="Successfully retrieved songs from Grooveshark.", data=[extract_song_data(song) for song in songs], status=200) else: resp = response(messages="No results found for: {0}".format(term), status=404) return resp