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

need a demo script #135

Closed nyck33 closed 4 years ago

nyck33 commented 4 years ago

I used what you have on readme to make a simple script:

import lyricsgenius

genius = lyricsgenius.Genius("my_token")
# set params
genius.verbose = False # Turn off status messages
genius.remove_section_headers = True # Remove section headers (e.g. [Chorus]) from lyrics when searching
genius.skip_non_songs = False # Include hits thought to be non-songs (e.g. track lists)
genius.excluded_terms = ["(Remix)", "(Live)"] # Exclude songs with these words in their title

artist = genius.search_artist("2pac", max_songs=3, sort="title")

print(artist.songs)
artist.save_lyrics()

but actually the song lyrics are embedded in a singleline within the json of unnecessary info:

  {
     "relationship_type": "performed_live_as",
     "type": "performed_live_as",
     "songs": []
    }
   ],
   "verified_annotations_by": [],
   "verified_contributors": [],
   "verified_lyrics_by": [],
   "writer_artists": [],
   "lyrics": "Woman \u2013 Sir, will you raise your right 

I guess I can extract the lyrics from this but is there a simpler way of getting one text file with all of 2pac's songs?

johnwmillr commented 4 years ago

Hi there,

Try changing the extension parameter to txt:

artist.save_lyrics(extension='txt')

Does that work for you?

allerter commented 4 years ago

Closing this as it seems to be solved.

johnwmillr commented 4 years ago

Additional documentation is available here.