Last active
May 22, 2019 16:48
-
-
Save crawftv/8bdfbe8ce23903cc816f7a5639ce195e to your computer and use it in GitHub Desktop.
Genius API Song Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def request_song_info(session, song_num, song_urls): | |
base_url = "https://api.genius.com/songs/" + str(song_num) | |
headers = {"Authorization": "Bearer " + CLIENT_ACCESS_TOKEN} | |
response = requests.get(base_url, headers=headers) | |
try: | |
if response.json()["meta"]["status"] == 200: | |
song_urls.append( | |
( | |
song_num, | |
response.json()["response"]["song"]["title"], | |
response.json()["response"]["song"]["url"], | |
) | |
) | |
else: | |
pass | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment