Skip to content

Instantly share code, notes, and snippets.

@crawftv
Last active May 22, 2019 16:48
Show Gist options
  • Save crawftv/8bdfbe8ce23903cc816f7a5639ce195e to your computer and use it in GitHub Desktop.
Save crawftv/8bdfbe8ce23903cc816f7a5639ce195e to your computer and use it in GitHub Desktop.
Genius API Song Query
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