def play_playlist(self):
        """plays the selected playlist in an ordered or shuffled way"""
        print("Playing all the songs in the selected playlist\
            \n\nnext - to play the next song in playlist\
            \n\nstop - to stop the playback and return to main menu\
            \n\nfav - to add to favourites\
            \n\npause - to pause the playback\
            \n\nplay - to resume the playback\
            \n\nmain - to go back to the main menu\
            \n\nlyrics - to search for lyrics")

        play = True
        while play:
            for song in self.selected_playlist:
                pygame.mixer.music.load(song)
                print("\n" + "-" * 150 + "\n" + "Currently Playing : " + song)
                current_song = pygame.mixer.Sound(song)
                print("length: ", int(current_song.get_length() // 60), "min",
                      math.floor(current_song.get_length()) % 60, "seconds")
                print('-' * 150)
                pygame.mixer.music.play(0)

                playing = True
                while playing:
                    user_choice = input("what do you want to do:")
                    if user_choice == 'next':
                        # exits this while loop
                        pygame.mixer.music.stop()
                        playing = False
                    elif user_choice == 'stop':
                        # exits all the loops
                        pygame.mixer.music.stop()
                        playing = False

                    elif user_choice == 'fav':
                        self.favourites(song)
                    elif user_choice == 'pause':
                        pygame.mixer.music.pause()
                    elif user_choice == 'play':
                        pygame.mixer.music.unpause()
                    elif user_choice == 'main':
                        playing = False
                    elif user_choice == 'lyrics':
                        lyrics.get_lyrics()

                    else:
                        print("Invalid Input! Try (play,pause,stop,fav,next) ")
                if user_choice == 'stop' or user_choice == 'main':
                    play = False
                    break
Beispiel #2
0
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    data = [{"labels": labels, "values": values, "type": "pie"}]

    return jsonify(data)
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    # @TODO: Create a Plotly trace, 'data', to return to the client
    data = [{"labels": labels, "values": values, "type": "pie"}]
    return jsonify(data)
Beispiel #4
0
def save_track(track, album_id, image_id):
    """Save track `track` from album `album_id` with image
    `image_id`. Return the saved song's ID."""
    song = {
        'name': track['recording']['title'],
        'mbid': track['id'],
        'length': get_song_length(track),
        'track_number': track['number'],
        'album_id': album_id,
        'image_id': image_id,
        'lyrics': lyrics.get_lyrics(track)
    }
    song['active'] = song['length'] > 0

    song_id = db.save('song', song)

    featured = track['recording']['artist-credit'][1:]
    for artist in featured:
        if isinstance(artist, str):
            continue  # skip strings like '&' and 'feat.'
        artist_id = save_artist(artist['artist'])
        db.save('song_featured_artists', (song_id, artist_id))

    save_genres(song_id, track['recording'])
    return song_id
Beispiel #5
0
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    # @TODO: Create a Plotly trace, 'data', to return to the client

    return jsonify(data)
Beispiel #6
0
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    # @TODO: Build a dictionary of the lyric data that you can use to
    # build a plotly pie chart
    data = [{"labels": labels, "values": values, "type": "pie"}]
    return jsonify(data)
Beispiel #7
0
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    # @TODO: Build a dictionary of the lyric data that you can use to
    # build a plotly pie chart

    return jsonify(data)
Beispiel #8
0
 def do_lyrics(self, s):
     track = sonos_actions.current_track_info(text=False)
     if track:
         lyric = lyrics.get_lyrics(track['artist'], track['title'])
         if lyric:
             self.msg = "\n"+"\n".join(lyric)
         else:
             self.msg = self.colorize(f"The track {track['title']} does not have lyrics available", 'red')
     else:
         self.msg = self.colorize("Nothing appears to be playing or there was another problem", 'red')
Beispiel #9
0
 def do_lyrics(self, s):
     track = sonos_actions.current_track_info(text=False)
     if track:
         lyric = lyrics.get_lyrics(track['artist'], track['title'])
         if lyric:
             self.msg = "\n"+"\n".join(lyric)
         else:
             self.msg = colorize(f"The track {track['title']} does not have lyrics available", 'red')
     else:
         self.msg = colorize("Nothing appears to be playing or there was another problem", 'red')
def rick():

    lyrics = get_lyrics()
    labels, values = zip(*lyrics.items())
    # @TODO: Build a dictionary of the lyric data that you can use to
    # build a plotly pie chart
    l_list = v_list = []

    data = [{'labels': labels, 'values': values, 'type': "pie"}]

    return jsonify(data)
Beispiel #11
0
 async def on_message(self, message):
     text = message.content
     if (message.author == self.user):
         return
     if (text.startswith("&")):
         text = message.content[1:].strip()
         lyrics = get_lyrics(text)
         await message.channel.send(lyrics)
         # print(text)
     else:
         return
Beispiel #12
0
def main():
    artist = 'Radiohead'.lower()

    disc = lyrics.get_unique_discography()
    disc = lyrics.clean_discography(disc)
    disc['Lyrics'] = [
        lyrics.get_lyrics(row.Track) for row in disc.itertuples()
    ]
    print('done')
    disc.to_csv(
        r'C:\Users\Gabe Freedman\Desktop\Projects\music_vocab\test.csv',
        index=False)
Beispiel #13
0
def find_song(search_words, sentiment):
    spotify_data = spotify.get_tracks(spotify_token, search_words, 20)

    if len(spotify_data) < 1:
        return None

    selected_song = spotify_data[0]
    for song in spotify_data:
        text = lyrics.get_lyrics(song["artist"], song["name"])
        song_sentiment = sentiments.analyze_sentiment(text)

        if song_sentiment is None:
            continue

        if abs(song_sentiment - sentiment) <= SENTIMENT_THRESHOLD:
            selected_song = song
            break

    return selected_song["url"]
Beispiel #14
0
def parse_data(result):
    data = result['tracks']['items']

    for item in data:

        track_id = item['id']

        artist_id = item['album']['artists'][0]['id']
        artist_details = spotify.artist(artist_id)

        album_tracks = spotify.album_tracks(item['album']['id'])
        album_track = []

        album_recommendations = []

        recommendations = spotify.recommendations(
            seed_tracks=["{}".format(track_id)], limit=4)
        for r in recommendations['tracks']:
            album_recommendations.append({
                "album_art":
                r['album']['images'][0]['url'],
                "album_name":
                r['album']['name'],
                "name":
                r['name'],
                "url":
                r['external_urls']['spotify']
            })

        for tracks in album_tracks['items']:
            album_track.append({
                "name": tracks['name'],
                "url": tracks['external_urls']['spotify']
            })

        artist = {
            "image": artist_details['images'][1]['url'],
            "name": artist_details['name']
        }

        album = {
            "name": item['album']['name'],
            "art": item['album']['images'][1]['url'],
            "tracks": album_track,
            "recommendations": album_recommendations
        }

        track = {
            "name": item['name'],
            "url": item['external_urls']['spotify'],
            'popularity': item['popularity'],
            "id": track_id
        }

        lyrics = get_lyrics.get_lyrics(track['name'], artist['name'])

    track_details = Song.Song(artist_name=artist['name'],
                              artist_image=artist['image'],
                              album_name=album['name'],
                              album_art=album['art'],
                              album_tracks=album['tracks'],
                              track_name=track['name'],
                              url=track['url'],
                              popularity=track['popularity'],
                              id=track['id'],
                              recommendations=album['recommendations'],
                              lyrics=lyrics)

    return track_details
Beispiel #15
0
def sample_metadata(song_title):
    lyrics = get_lyrics(song_title)
    return jsonify(lyrics)
Beispiel #16
0
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    print(content_type, chat_type, chat_id)
    if content_type == 'text':
        input = str(msg['text']).lower()
        if input == 'hi' or input == 'hey' or input == 'hello':
            bot.sendMessage(chat_id, 'Hey ' + msg['from']['first_name'] + '!')
            time.sleep(1.5)
            bot.sendMessage(
                chat_id,
                'I am Marco Polo, or just Marc. With me, you get to discover new foreign music AND enhance your vocabulary. You will learn rare words, words that will make other language learners marvel at your knowledge!'
            )
            time.sleep(3.5)
            bot.sendMessage(
                chat_id,
                'But first of all, tell me what language you plan to study.')
        elif input == 'marco' or input == 'Marco':
            bot.sendMessage(chat_id, 'Polo!')
        elif input == 'great' or input == 'Great':
            bot.sendMessage(chat_id, 'Schoene Tag noch ;)')
        else:
            bot_resp = callLUIS(input)
            action, score = parseIntent(bot_resp)
            entities = parseEntities(bot_resp)
            #pass entities as search criteria
            bot.sendMessage(chat_id, 'Ok, ' + entities[-1][1] + ' it is!')
            bot.sendMessage(
                chat_id,
                'I  will crammed through the lyrics of some interesting songs!\n'
            )
            time.sleep(1.5)
            bot.sendMessage(chat_id, 'Give me a second ...')
            seed()
            i = randint(0, 2)
            j = randint(0, 2)
            songs = get_songs([WORDS[entities[-1][0]][i][j]], 20)
            print[WORDS[entities[-1][0]][i][j]]
            lyrics = None
            song = None
            k = 0
            while not lyrics:
                song = songs[k]
                lyrics = get_lyrics(song['artist'], song['name'])
                k += 1
            lyrics = lyrics.split()
            words = set([])
            while len(words) < 3:
                word = choice(lyrics)
                if len(word) > 4:
                    words.add(word)
            # find the right one
            #print words
            k = randint(0, len(songs))
            wordlist = list(words)
            bot.sendMessage(chat_id, song['url'])
            bot.sendMessage(chat_id, ' Just listen to it and get back to me!')
            bot.sendMessage(
                chat_id,
                'Now I  gonna ask you some words that you might recognize from the song you just heard. If you don\'t know them already let\'s learn them!'
            )
            bot.sendMessage(chat_id,
                            'What does ' + wordlist[1] + ' mean in English?')
            print wordlist[1]
            time.sleep(1.5)
            best_match = translate(str(wordlist[1]), 'de', 'en')[0]
            bot.sendMessage(chat_id,
                            'It means ' + best_match[1] + ' in English')
            time.sleep(1.5)
            bot.sendMessage(chat_id, 'Great eh? :) ')
            print best_match
def get_lyrics_song_name(songname):
    return lyrics.get_lyrics(songname)
Beispiel #18
0
import lyrics, json

file_ = open('data.json', 'r')
f = file_.read()
j = json.loads(f)
out = open('dataset.txt', 'w')

for el in j:
    print('getting', el['name'], '  ', el['title'])
    out.write(lyrics.get_lyrics(el['name'], el['title']))

print('DONE')