cmdStr = input("cmd:/ ") tokens = cmdStr.split(' ',1) if(len(tokens) < 2): print("Invalid command. Try again") continue cmd = tokens[0].upper() if(cmd == "PLAYLIST"): if(len(tokens) < 2): print("Invalid format. Try again") continue letter = tokens[1].upper() printRadioOnePlaylist(letter) elif(cmd == "COMPARE"): artists = tokens[1].split(":") if(len(tokens) < 2): print("Invalid format. Try again") continue artist1 = artists[0] artist2 = artists[1] rank1 = int(checkSpotifyPopularity(artist1)) rank2 = int(checkSpotifyPopularity(artist2)) print("-"*50) if(rank1 < rank2):
# In the separate Python file MusicAPIFunctions.py I have defined 2 functions. # The next line allows those functions to be used in this script. from MusicAPIFunctions import checkSpotifyPopularity, printRadioOnePlaylist # The functions use information stored on the internet regarding music. # We give examples of each # 1. checkSpotifyPopularity finds the current popularity rating for an artist on spotify. # Example: print("-" * 50) print("Example of checkSpotifyPopularity") print("-" * 50) print(checkSpotifyPopularity("Royal Blood")) print("") # 2. printRadioOnePlaylist prints the songs currently being played regularly on BBC Radio 1. # There are 4 different playlists, indexed by letters A,B,C and I (for introducing). # Example: pl = printRadioOnePlaylist("A")
# In the separate Python file MusicAPIFunctions.py I have defined 2 functions. # The next line allows those functions to be used in this script. from MusicAPIFunctions import checkSpotifyPopularity, printRadioOnePlaylist # The functions use information stored on the internet regarding music. # We give examples of each # 1. checkSpotifyPopularity finds the current popularity rating for an artist on spotify. # Example: print("-"*50) print("Example of checkSpotifyPopularity") print("-"*50) print( checkSpotifyPopularity("Royal Blood") ) print("") # 2. printRadioOnePlaylist prints the songs currently being played regularly on BBC Radio 1. # There are 4 different playlists, indexed by letters A,B,C and I (for introducing). # Example: pl = printRadioOnePlaylist("A")