Example #1
0
def get_bl_info():
    song_id = int(request.args["song"])
    for i in range(black_list.songs_length()):
        if black_list._songs_data[i].track_id == song_id:
            name = black_list._songs_data[i]
            video = YouTube(name.iri_artist, name.iri_track_name)
            video.get_info()
            return render_template("track.html", name=name, video=video)
Example #2
0
def add_blacklist_artist():
    """
    Adds artist to the blacklist.
    :return: track.html
    """
    name = songs[request.args["song"]]
    black_list.add_artist(name.artist)
    video = YouTube(name.iri_artist, name.iri_track_name)
    video.get_info()
    return render_template("track.html", name=name, video=video)
Example #3
0
def add_playlist():
    """
    Adds song to the playlist.
    :return: track.html
    """
    name = songs[request.args["song"]]
    play_list.add(name)
    video = YouTube(name.iri_artist, name.iri_track_name)
    video.get_info()
    return render_template("track.html", name=name, video=video)
Example #4
0
def show_track_info(name):
    """
    Shows track info.
    :param name: track full name
    :return:
    """
    name = songs[name]
    # name.get_lyrics()
    # name.lyrics = name.lyrics.split('\n')
    video = YouTube(name.iri_artist, name.iri_track_name)
    video.get_info()
    return render_template("track.html", name=name, video=video)
Example #5
0
def maiin():
    playlist = PlayList()
    blacklist = BlackList()

    songs_list = show_search_results(blacklist)

    while True:
        print()
        print('''
Commands:

playlist - Shows your playlist
blacklist - Shows your blacklist
track {track number} - Shows information about track(Input example: track 3)
search - Shows search menu
find - Shows potentially interesting songs by playlist 
exit - Stop the program
        ''')
        answer = input('>>> ')
        if answer == 'playlist':
            while True:
                print(playlist)
                print('''
Commands:

back - Back to the main menu
clear - Clears the playlist
remove {track number} - Removes this track from the playlist(Input example: remove 3)
return - Changes you playlist to the previous status
                    ''')
                answer = input('>>> ')
                if answer == 'clear':
                    playlist.clear()
                elif len(answer) >= 8:
                    if answer[:7] == 'remove ':
                        try:
                            playlist.remove(int(answer[7:]) - 1)
                        except AssertionError:
                            print('Wrong track.')
                elif answer == 'return':
                    playlist.pull_back()
                elif answer == 'back':
                    break
                else:
                    print('Wrong command.')
        elif answer == 'blacklist':
            while True:
                print(blacklist)
                print('''
Commands:

back - Back to the main menu
clear - Clears the blacklist
remove song {track number} - Removes this song from the blacklist(Input example: remove song 3)
remove genre {genre number} - Removes this genre from the blacklist(Input example: remove genre 3)
remove artist {artist number} - Removes this artist from the blacklist(Input example: remove artist 3)
                    ''')
                answer = input('>>> ')
                if answer == 'clear':
                    playlist.clear()
                elif len(answer) >= 12:
                    if answer[:12] == 'remove song ':
                        try:
                            blacklist.remove_song(int(answer[12:]) - 1)
                        except AssertionError:
                            print('Wrong track.')
                    if answer[:13] == 'remove genre ':
                        try:
                            blacklist.remove_genre(int(answer[13:]) - 1)
                        except AssertionError:
                            print('Wrong genre.')
                    if answer[:14] == 'remove artist ':
                        try:
                            blacklist.remove_artist(int(answer[14:]) - 1)
                        except AssertionError:
                            print('Wrong artist.')
                elif answer == 'back':
                    break
                else:
                    print('Wrong command.')
        elif len(answer) >= 7:
            if answer[:6] == 'track ':
                try:
                    song = songs_list[int(answer[6:]) - 1]
                    youtube_info = YouTube(song.artist, song.track_name)
                    youtube_info.get_info()
                    track_information(song, youtube_info)
                    while True:
                        print('''
Commands:

back - Back to the main menu
add to playlist - Add this song to the playlist
add to blacklist - Add this song to the blacklist
add genre to blacklist - Add the genre of this song to the blacklist
add artist to blacklist - Add the artist to the blacklist
lyrics - Get the lyrics
find by genre - Shows potentially interesting songs by genre
find by artist - Shows potentially interesting songs by artist 
                    ''')
                        answer = input('>>> ')
                        if answer == 'add to playlist':
                            playlist.add(song)
                            print('Added!')
                        elif answer == 'add to blacklist':
                            blacklist.add_song(song)
                            print('Added!')
                        elif answer == 'add genre to blacklist':
                            blacklist.add_genre(song.genre)
                            print('Added!')
                        elif answer == 'add artist to blacklist':
                            blacklist.add_artist(song.artist)
                            print('Added!')
                        elif answer == 'lyrics':
                            if not song.lyrics:
                                song.get_lyrics()
                            print('''
Lyrics:\n{}
                            '''.format(song.lyrics))
                        elif answer == 'find by genre':
                            songs_list = create_search_list(
                                song.genre, blacklist)
                            for track_num in range(len(songs_list)):
                                print(track_num + 1, songs_list[track_num])
                            break
                        elif answer == 'find by artist':
                            songs_list = create_search_list(
                                song.artist, blacklist)
                            for track_num in range(len(songs_list)):
                                print(track_num + 1, songs_list[track_num])
                            break
                        elif answer == 'back':
                            break
                        else:
                            print('Wrong command.')
                except IndexError:
                    print('Wrong track.')
        elif answer == 'search':
            songs_list = show_search_results(blacklist)
        elif answer == 'find':
            songs_list = find_by_playlist(songs_list, playlist, blacklist)
        elif answer == 'exit':
            break
        else:
            print('Wrong command')