Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import spotipy
- from spotipy.oauth2 import SpotifyClientCredentials
- dicto = {"BASS": ["ALLEYCVT",
- "ATLiens",
- "Barclay Crenshaw",
- "Black Tiger Sex Machine",
- "Caspa",
- "Chase & Status",
- "Dimension",
- "Excision",
- "Gigantic NGHTMRE",
- "Hamdi",
- "LEVEL UP",
- "Lucii",
- "LYNY",
- "LSZEE",
- "Sammy Virji",
- "Subtronics",
- "venbee",
- "Whyte Fang",
- "Wooli",
- "Seven lions",
- "G jones",
- "Boogie T",
- "CannaBliss",
- "Ivy Lab",
- "levity",
- "Super Future",
- "Zen Selekta",],
- "HOUSE": ["ACRAZE",
- "AYYBO",
- "Ben Bohmer",
- "Calussa",
- "Cassian",
- "Charlotte De Witte",
- "Coco & Breezy",
- "DJ Tennis",
- "DRAMA",
- "EVERYTHING ALWAYS",
- "Green Velvet",
- "it's murph",
- "John Summit",
- "Knock2",
- "Le Youth",
- "LP Giobbi",
- "Major League Djz",
- "Matroda",
- "Mau P",
- "Michael Brun",
- "ODEN & Fatzo",
- "Ranger Trucco",
- "Sultan + Shepard",
- "TSHA",
- "Vini Vici",
- "VNSSA B2B Nala",
- "Westend",
- "Will Clarke",
- "Sara Landry",
- "Baggi",
- "Brandi Cyrus",
- "Chaos in CBD",
- "DJ Susan",
- "H&RRY",
- "Layton Giordani",
- "marsh",
- "MASONIC",
- "Mojave Grey",
- "odd Mob",
- "Only fire",
- "Rayben",
- "Shae District",
- "Swaylo",],
- "INDIE": ["Cuco",
- "NEIL FRANCES",
- "Peach Tree Rascals",
- "Emo Nite",
- "Equanimous",
- "Kiltro",],
- "POP": ["Cannons",
- "Mascolo",
- "Nelly Furtado",
- "Slayyyter",
- "Neoma",
- "Unusual demont",],
- "JAM": ["Dirtwire",
- "Dumpstaphunk",
- "Eggy",
- "Lettuce",
- "Pretty Lights",
- "Disco Biscuits",
- "String Cheese Incident",
- "Umphrey's McGee",
- "Jjuujjuu",
- "Proxima Parada",],
- "TRAP": ["INZO",
- "Juelz",
- "Maddy O'Neal",
- "Redrum",
- "Thought process",
- "Tripp St.",],
- "RAP": ["Kenny Beats",
- "Libianca",
- "Ludacris",
- "PAPERWATER",
- "hiatus kaiyote",
- "Little stranger",],
- "SOUL": ["Dixon's Violin",
- "Rawayana",
- "Polyrhythmics",]
- }
- for_spotify ={ "Chaos in CBD" : "Chaos In The CBD",
- "Disco Biscuits": "The Disco Biscuits",
- "Proxima Parada" : "Próxima Parada",
- "String Cheese Incident" : "The String Cheese Incident",
- "Gigantic NGHTMRE" : "Big Gigantic",
- "EVERYTHING ALWAYS" : "Dom Dolla",
- "LSZEE": "CloZee",
- "Michael Brun" : "Michaël Brun",
- "Ben Bohmer" : "Ben Böhmer"}
- STAGES = [ "RANCH_ARENA", "SHERWOOD_COURT", "TRIPOLEE", "CAROUSEL_CLUB", "OBSERVATORY", "HONEYCOMB"]
- '''
- {
- .artist = "EZBK ",
- .stage = RANCH_ARENA,
- .start_time = {.unit.year = 4, .unit.month = 6, .unit.day = 20, .unit.hour = 15, .unit.minute = 0},
- .end_time = {.unit.year = 4, .unit.month = 6, .unit.day = 20, .unit.hour = 16, .unit.minute = 0},
- .genre = TRAP,
- },
- '''
- def get_artist(artist_name):
- client_id = 'REDACTED'
- client_secret = 'REDACTED'
- artist_name = for_spotify.get(artist_name, artist_name)
- first_match = False
- if "'" in artist_name:
- first_match = True
- artist_name = artist_name.replace("'", "")
- # Authenticate with Spotify
- auth_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
- sp = spotipy.Spotify(auth_manager=auth_manager)
- # Search for the artist
- result = sp.search(q='artist:' + artist_name, type='artist')
- artist_results = result['artists']['items']
- if not artist_results:
- print(f"FAILED TO FIND: {artist_name}")
- return None
- artist_info = None
- names_in_search = []
- for option in artist_results:
- name = option['name']
- if first_match:
- #print(f"BEST MATCH for :{artist_name} is {name}")
- artist_info = option
- break
- names_in_search.append(name)
- if name.upper() == artist_name.upper():
- #print(f"Found {name}")
- artist_info = option
- break
- if artist_info is None:
- print(f"FAILED TO FIND: {artist_name}, BUT FOUND {names_in_search}")
- return None
- return artist_info
- def get_artist_followers_popularity(artist_name):
- artist_info = get_artist(artist_name)
- if artist_info is None:
- return 0,0
- followers = artist_info['followers']['total']
- popularity = artist_info['popularity']
- return followers, popularity
- def rank_artists_by_popularity(artists):
- # Sort artists by popularity in descending order
- sorted_artists = sorted(artists, key=lambda x: x['followers'], reverse=True)
- # Create a dictionary to store the ranks
- artist_ranks = {}
- # Assign ranks starting from 1
- for rank, artist in enumerate(sorted_artists, start=1):
- artist_ranks[artist['name']] = rank
- return artist_ranks
- def findGenre(act):
- for key in dicto:
- for i in dicto[key]:
- if i.upper() == act.upper():
- return key.upper()
- return -1
- def get_overall_ranking(artists, name):
- for artist in artists:
- if artist['name'].lower() == name.lower():
- return artist['overall']
- return None
- # Spits out the array of acts in alphabetically order.
- listActs = []
- for key in dicto:
- for i in dicto[key]:
- listActs.append(i)
- listActs = sorted(listActs, key=str.casefold)
- listActsPop = []
- print("act, followers, popularity")
- for act in listActs:
- followers, popularity = get_artist_followers_popularity(act)
- print(f"{act}, {followers}, {popularity}")
- listActsPop.append({'name':act, 'followers' : followers, "popularity" : popularity})
- sorted_listing = sorted(listActsPop, key=lambda x: (x['popularity'], x['followers']), reverse=True)
- # Add an "overall" key
- for i, artist in enumerate(sorted_listing):
- artist['overall'] = i + 1
- for i, act in enumerate(listActs):
- print(" {")
- print(f' .artist = "{act.upper()[:6]}",')
- print(f' .stage = {STAGES[i % len(STAGES)]},')
- print(" .start_time = {.unit.year = 4, .unit.month = 6, .unit.day = 20, .unit.hour = 15, .unit.minute = 0},")
- print(" .end_time = {.unit.year = 4, .unit.month = 6, .unit.day = 20, .unit.hour = 16, .unit.minute = 0},")
- print(f' .genre = {findGenre(act)},')
- print(f' .popularity = {get_overall_ranking(sorted_listing, act)}')
- print(" },")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement