johnwmillr / LyricsGenius

Download song lyrics and metadata from Genius.com 🎶🎤
http://www.johnwmillr.com/scraping-genius-lyrics/
MIT License
898 stars 159 forks source link

Get URL of song page #141

Closed BirdLeaflol closed 4 years ago

BirdLeaflol commented 4 years ago

Would it be possible to add a feature that allows me to get the URL of a song page, or if this already exists, could you tell me how to do it?

allerter commented 4 years ago

If I've understood your question correctly, the URL of each song is in its JSON file, can be accessed through song.url after a song is fetched. If you want to read the URLs of an artist you've saved:

with open('lyrics.json','r') as f:
    data = json.load(f)
for song in data['songs']:
    print(song['url'])

I suggest using the tree viewer feature of services like Code Beautify to see what info the saved JSON file holds.