Skip to content

Instantly share code, notes, and snippets.

@dahliahadfury
Last active September 21, 2020 20:06
Show Gist options
  • Save dahliahadfury/95014e8005d9f7bb2789b6b5959d7c1d to your computer and use it in GitHub Desktop.
Save dahliahadfury/95014e8005d9f7bb2789b6b5959d7c1d to your computer and use it in GitHub Desktop.
cas song
import lyricsgenius
genius = lyricsgenius.Genius("TOKEN")
artist = genius.search_artist("Cigarettes After Sex", max_songs=100, sort="title")
artist.to_json("songs.json")
with open('songs.json') as json_file:
data = json.load(json_file)
for item in data["songs"]:
api_path = item["api_path"]
title = item["title"]
try:
spotify_url = item["media"][0]["url"]
album = item["album"]["name"]
except:
spotify_url = None
album = None
release_date = item["release_date"]
header_image_thumbnail_url = item["header_image_thumbnail_url"]
header_image_url = item["header_image_url"]
url = item["url"]
lyrics = item["lyrics"]
cas_song = cas_song.append({"api_path":api_path,
"title":title,
"album":album,
"release_date":release_date,
"header_image_thumbnail_url":header_image_thumbnail_url,
"header_image_url":header_image_url,
"url":url,
"lyrics":lyrics,
"spotify_url":spotify_url}, ignore_index=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment