Exemplo n.º 1
0
    def currently_playing(self):
        song = self.is_playing()

        if not song:
            return ""
        else:
            return "**Currently Playing** " + self.format_song(extract_song_data(song)) + "\n"
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    def currently_playing(self):
        song = self.is_playing()

        if not song:
            return ""
        else:
            return "**Currently Playing** " + self.format_song(
                extract_song_data(song)) + "\n"
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
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