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):
			print(artist1.upper() + "(rank: " + str(rank1) + ") is more popular than " + artist2.upper() + "(rank: " + str(rank2) + ")")
		elif(rank2 < rank1):
			print(artist2.upper() + "(rank: " + str(rank2) + ") is more popular than " + artist1.upper()	+ "(rank: " + str(rank1) + ")")
		else:
			print("You can't compare artist to himself. Try again.")
			continue
		print("-"*50)
	
	elif(cmd == "QUIT"):
		break
	
コード例 #2
0
# 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")
コード例 #3
0
# 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")