!pip install git+https://github.com/johnwmillr/LyricsGenius.git
34 Song Lyrics Collection
In this lesson, we’re going to use a Python package called LyricsGenius to collect song lyrics about any artist and album.
34.1 API Wrappers
An API wrapper is a package that makes an API easier to use and/or extends the API’s functionality. A data scientist named John Miller wrote a Python package called LyricsGenius, which makes working with the Genius API easier and adds functionality not offered by the Genius API.
Remember when I said that companies typically don’t offer access to their most lucrative data? Well, the Genius API doesn’t offer you a way to get access to song lyrics. To solve this problem, LyricsGenius combines the Genius API with the web scraping library BeautifulSoup to get and save song lyrics.
34.2 Install the Package
To install LyricsGenius (and get the most updated version from GitHub), run:
Copy and paste your Genius “Client Access Token” into the quotation marks below, and run the cell to save your variable :
= "INSERT YOUR CLIENT ACCESS TOKEN IN THESE QUOTATION MARKS" client_access_token
Import and initialize LyricsGenius
import lyricsgenius
= lyricsgenius.Genius(client_access_token) LyricsGenius
34.3 Get Songs and Lyrics By a Specific Artist
To get the top songs and song lyrics from a specific artist you can use the method .search_artist()
:
= LyricsGenius.search_artist("Missy Elliott", max_songs=6) artist
Searching for songs by Missy Elliott...
Song 1: "Work It"
Song 2: "WTF (Where They From)"
Song 3: "Get Ur Freak On"
Song 4: "I’m Better"
Song 5: "Gossip Folks"
Song 6: "The Rain (Supa Dupa Fly)"
Reached user-specified song limit (6).
Done. Found 6 songs.
To access the song titles, you can run artist.songs
:
artist.songs
[('Work It', 'Missy Elliott'),
('WTF (Where They From)', 'Missy Elliott'),
('Get Ur Freak On', 'Missy Elliott'),
('I’m Better', 'Missy Elliott'),
('Gossip Folks', 'Missy Elliott'),
('The Rain (Supa Dupa Fly)', 'Missy Elliott'),
('Lose Control', 'Missy Elliott'),
('One Minute Man', 'Missy Elliott'),
('Pass That Dutch', 'Missy Elliott'),
('Hot Boyz (Remix)', 'Missy Elliott')]
Inside each of those songs, LyricsGenius has already saved the song lyrics. You can access these lyrics by looping through artist.songs
and pulling out song.lyrics
:
for song in artist.songs:
print(song.lyrics)
[Intro]
DJ, please pick up your phone, I'm on the request line
This is a Missy Elliott one-time exclusive, come on
[Chorus]
Is it worth it? Let me work it
I put my thing down, flip it and reverse it
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
If you got a big *elephant trumpet*, let me search ya
And find out how hard I gotta work ya
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
C'mon
[Verse 1]
I'd like to get to know ya so I could show ya
Put the pussy on ya like I told ya
Give me all your numbers so I can phone ya
Your girl acting stank, then call me over
Not on the bed, lay me on your sofa
Call before you come, I need to shave my chocha
You do or you don't or you will or won't ya?
Go downtown and eat it like a vulture
See my hips and my tips, don't ya?
See my ass and my lips, don't ya?
Lost a few pounds and my waist for ya
This the kinda beat that go ra-ta-ta
Ra-ta-ta-ta-ta-ta-ta-ta-ta-ta
Sex me so good I say blah-blah-blah
Work it, I need a glass of water
Boy, oh boy, it's good to know ya
C'mon
[Chorus]
Is it worth it? Let me work it
I put my thing down, flip it and reverse it
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
If you got a big *elephant trumpet*, let me search ya
And find out how hard I gotta work ya
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
C'mon
[Verse 2]
If you a fly gal, get your nails done
Get a pedicure, get your hair did
Boy, lift it up, let's make a toast-a
Let's get drunk, that's gonna bring us closer
Don't I look like a Halle Berry poster?
See the Belvedere playing tricks on ya
Girlfriend wanna be like me, never
You won't find a bitch that's even better
I make you hot as Las Vegas weather
Listen up close while I take it backwards
sdrawkcab ti ekat ot ekil yssiM yaw eht hctaW
I'm not a prostitute, but I could give you what you want
I love your braids and your mouth full of fronts
Love the way my ass go bum-bum-bum-bum
Keep your eyes on my bum-bum-bum-bum-bum
You think you can handle this badonka-donk-donk
Take my thong off and my ass go boom
Cut the lights on so you see what I could do
C'mon
[Chorus]
Is it worth it? Let me work it
I put my thing down, flip it and reverse it
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
If you got a big *elephant trumpet*, let me search ya
And find out how hard I gotta work ya
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
C'mon
[Verse 3]
Boys, boys, all type of boys
Black, White, Puerto Rican, Chinese boys (C'mon)
Why-thai, thai-o-toy-o-thai-thai
Rock-thai, thai-o-toy-o-thai-thai (C'mon)
Girls, girls, get that cash
If it's 9 to 5 or shaking your ass (Aha)
Ain't no shame, ladies do your thing (C'mon)
Just make sure you ahead of the game
Just 'cause I got a lot of fame super
Prince couldn't get me change my name, papa
Kunta Kinte a slave again, no sir
Picture blacks saying, “Oh yes'a, massa”
Picture Lil' Kim dating a pastor
Minute Man and Big Red could outlast ya
Who is the best? I don't have to ask ya
When I come out, you won't even matter
Why you act dumb like, uh, duh?
So you act dumb like, uh, duh
As the drummer boy go ba-rom-pop-pom-pom
Give you some-some-some of this Cinnabun
C'mon
[Chorus]
Is it worth it? Let me work it
I put my thing down, flip it and reverse it
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
If you got a big *elephant trumpet*, let me search ya
And find out how hard I gotta work ya
Ti esrever dna ti pilf, nwod gniht ym tup
Ti esrever dna ti pilf, nwod gniht ym tup
C'mon
[Outro]
To my fellas (Ooh good god!)
I like the way you work that (Uh huh, la-la-la-la)
To my ladies (Whoo! Good god!)
You sure know how to work that
Yeah, it's Missy Elliott!
I hope y'all enjoying what y'all heard so far
I was sittin' here thinkin' like
Big Daddy Kane and Public Enemy
Salt n Pepa, Lyte, EPMD, LL, Run-DMC
KRS-One, Rakim
Most of them artists used to dance
And still get respected in the street
Don't be scared to Bankhead or Bogo
Or move as far as sold Michael Jackson 43 million
Shoot, errbody have the zipper jacket
And half of these thugs have the glove to match, ya feel me?
Yo, it's ok though, if you wanna be hard and ice grill
And Harlem Shake at the same time, whatever
Let's just have fun, it's hip-hop man, this is hip-hop!
[Produced by Pharrell]
[Intro]
[Hook: Missy Elliott (Pharrell)]
(Shorty what?)
The dance that you doing is dumb
How they do it where you from? (Ayy!, Triflin'!)
Stickin' out your tongue
Girl, but you know you're too young
A bunch of girls do it and the shit look fun
That's how they do it where we from (Ayy!)
You know it don't start till one
That's how they do it where they from
[Verse 1: Missy Elliott]
I'm so faded, no exaggeration (What?)
Backs breakin' like a percolation (What?)
Boys to the yard for some hip spankin'
Where you make it drop down like you in the matrix (Yeah!)
Can't take it, them chicks been fakin' (What?)
Y'all still sleep, better stay awakened (What?)
Hot new dance for the hood to make it
Make the donk move fast, make them think you drinkin' (Yeah!)
Head to the floor don't collect that though (What?)
You better huddle up cause the beat's so cold (Huh?)
Pop that, pop that, cock and reload (Huh?)
This another hit, I got an ace in the hole (What?)
Boys on my back, playa, did you peep that?
You got a small stack, playa, you can keep that (Huh?)
I'm a Big Mac make you wanna eat that
Like m-m-m-m-m, yak it to the yak (Yeah?)
Junk in the trunk make you pumps in the bump
Girls wanna have fun make you stickin' out your tongue (What?)
[Hook: Missy Elliott]
Shorty what?
The dance that you doing is dumb
How they do it where you from?
Stickin' out your tongue girl
But you know you're too young
A bunch of girls do it and the shit look fun
That's how they do it where we from
You know it don't start till one
That's how they do it where they from
[Verse 2: Pharrell]
I come into this bitch like liquid
Drip, drip, then the business
Click, click, get your picture
Hermés Trismegistus
Witness and get lifted
Basic, nigga I was born in the basement
Shape shift, nigga, I think like a spaceship
False, oh-nah-nah-nah
I am so different than y'all, so far apart
The way that I balance the bars
I never fall, and if I do I just call
The almighty yellow star, God
Lyrically I'm Optimus Prime
The car I drive; La FER-RAR-I
When I go by, smoke in your eyes
So open your eyes, the joke's on you guys
And you ain't gotta be a mason to see through
Some of this shit on occasion
[Hook: Missy Elliott]
Shorty what?
The dance that you doing is dumb
How they do it where you from?
Stickin' out your tongue, girl
But you know you're too young
A bunch of girls do it and the shit look fun
That's how they do it where we from
You know it don't start till one
That's how they do it where they from
[Verse 3: Missy Elliott]
I'm like kak-a-rak-a-rak-rak-a-rak-a-rak
Make a new track, make 'em fall on they crack
Give 'em a slap, appetizer and smack
I'm so fat in the back, make the boys all collapse
Yeah, when I rap they be all on my jack
Boys wanna jump on this pussy cat (Prrrr)
Got a new idea, let me switch it
Man, I'm so futuristic
Big lips and big, big, big hips
Body be thick like a biscuit
Different, rippin' shit, microphone grippin' it
Gettin' these Benjamins, new car, whippin' it
Uh, I'm so far ahead of ya'll, man I'm on top of the stars
I don't care none of you are, blah-blah-blah-blah
You best to go rewrite your bars
[Outro Missy Elliott & (Pharrell)]
Shawty what?
How they do it where you from? (Triflin'!)
How they do it where you from?
That's how they do it where we from
That's how they do it where they from
Shawty what?
How they do it where you from? (Hey!)
How they do it where you from?
That's how they do it where we from
That's how they do it where they from
[Intro]
Kore kara minna de mechakucha odotte
Sawago sawago!
Headbanger, hit me, hit me, hit me, hit me...
Yeah, gimme some new shit
Gimme some new shit
Gimme some new shit
Gimme some new shit
[Verse 1]
Missy be puttin' it down, I'm the hottest 'round
I told y'all motherfuckers, y'all can't stop me now
Listen to me now, I'm lastin' twenty rounds
And if you want me (nigga) then come on, get me now
Is you with me now? Then biggie, biggie bounce
I know you dig the way I sw-sw-switch my style
Holla
People sing around
Now people gather 'round, now people jump around
[Hook]
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
[Verse 2]
Who’s that bitch? People you know
Me and Timbaland been hot since twenty years ago
What tha dilly yo? Now what tha drilly yo?
If you wanna battle me then (nigga) let me know
Holla
Got to feel it, son
Lemme throw you some (maut mujhko)
People, here I come, now sweat me when I'm done
We got the radio shook like we got a gun
[Hook]
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
[Verse 3]
Quiet! (Shhh) Hush your mouth, silence when I spit it out
(Hah-choo!) In your face, open your mouth, give you a taste
Holla
Ain't no stoppin' me, copy written so don't copy me
Y'all do it sloppily and y'all can't come close to me
I know you feel me now, I know you hear me loud
I scream it loud and proud, Missy gon' blow it down
People gon' play me now, in and outta town
'Cause I'm the best around with this crazy style
[Hook]
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on, go, get your freak on
Go, get your freak on
Go, getcha getcha getcha getcha getcha freak on
[Outro]
Ichi, ni, san, ji
[Hook: Lamb]
I'mma start it from the bottom
Show you how to flip a dollar
I got food in my dining room
I'm better, I'm better, I'm better
It's another day, another chance
I wake up, I wanna dance
So as long as I got my friends...
I'm better, I'm better, I'm better
[Verse 1: Missy]
He say I'm hot, I'm so fuego
Pull up on him in my vehicle
He say I'm pretty, I'm pretty
You must be from Brazil, or must be from México
Roll up on him in my Lambo
Jump out like skrrrt, yeah bro
You need a chick like me to make you wanna leave them other broads, you don't know nann hoe
[Bridge: Missy]
Yeah he got bands in the Bando
Missy got dudes in Orlando
Plus I got cars that he paying for
Man I be too much to handle
Watch what I do, when I get up on you
Pop potential in my room and zoom in the poom
He watching my body like he watching Scandal
But I'm just here, with my girls
[Hook: Lamb]
I'mma start it from the bottom
Show you how to flip a dollar
I got food in my dining room
I'm better, I'm better, I'm better
It's another day, another chance
I wake up, I wanna dance
So as long as I got my friends...
I'm better, I'm better, I'm better
[Verse 2: Missy]
Missy so hot, I'm from VA
The car that I drive be Ferr-ar-i
My clique is so thick and the boys they be hollin' and whistlin'
At me like damn bae
Man I'm 3000, I'm André
Yo Missy talk big, I'm so grande
Bruce Lee on the beat, I don't compete with none of these geeks
I just rant like I'm Kanye
[Bridge 2: Missy]
Yeah he got bands in the Bando
Missy got dudes in Orlando
And I be driving cars he paying for
He say I'm too much, I'm a handful
He watching my body like watching he Scandal
But I'm just here, with my girls
[Hook: Lamb]
I'mma start it from the bottom
Show you how to flip a dollar
I got food in my dining room
I'm better, I'm better, I'm better
It's another day, another chance
I wake up, I wanna dance
So as long as I got my friends...
I'm better, I'm better, I'm better
[Verse 3: Missy]
Brand new flow when I rap
DJ, bring that back
You ain't ever heard a track like that
Shit might slap, booty go clap
Roll up in the Benz
Looking like a ten, stack
When I rock, make it bop, in my car
And it bang-bang-bang like (tune-out noise) go blap-blap-blap
[Bridge 3: Missy]
Yeah he got bands in the Bando
Missy got dudes in Orlando
Buying me bags and new shoes and new cars and everything I know that he paying for
Yeah he be hooking me up
Yeah he be looking me up
Watch what I do, when I get up on you
Pop potential and zoom in the poom
[Hook: Lamb]
I'mma start it from the bottom
Show you how to flip a dollar
I got food in my dining room
I'm better, I'm better, I'm better
It's another day, another chance
I wake up, I wanna dance
So as long as I got my friends...
I'm better, I'm better, I'm better
[Intro: People in background chatting]
Yo, yo yo move out of the way
We got Missy Elliott coming through
Girl that is Missy Elliott she lost a lot of weight
Girl I heard she eats one cracker a day
Oh well I heard the bitch was married to Tim and started fucking with Trina
I heard the bitch got hit with three zebras and a monkey
I can't stand the bitch no way
[Verse 1: Missy Elliott]
When I walk up in the piece
I ain't gotta even speak
I'm a bad mamajama
Goddammit motherfucker you ain't gotta like me
How you stuntin' these hoes
Need to talk what you know
And stop talking bout who I'm sticking and licking
Just mad it ain't yours
I know ya'll po' ya'll broke
Ya'll job just hanging up clothes
Step to me get burnt like toast
Muthafuckas, adios amigos
Halves halves wholes wholes
I don't brag I mostly boast
From the VA to the LA coast
Izzy kizzy lizzy goh
[Chorus]
Millze cillzan sillzome plilzay dilzzouble dilzutch!
Hilzzoo?
My gizzirl!
Brillzing her izzin!
Izzo kizzay!
Izzall rizzight...
Izzo kizzay!
Izzall rizzight! Nizzow wizzee wilzzo-izzo-zee!
[Verse 2: Missy Elliott]
When I pull up in my whip
Bitches wanna talk shit
I'm driving I'm glad and I'm styling
In these muthafuckas ask, did you see it?
I'm gripping these curbs
Skrrt Did ya heard?
I love em, my feathers, my furs
I fly like a bird
Chicken heads on the prowl
Who you trying fuck now?
Now you ain't getting loud
Better calm down 'for I smack your ass down
I need my drums bass high
Has to be my snare, strings, horns, yes
I need my Tim sound
Right, left
Izzy kizzy looky here
[Chorus]
Millze cillzan sillzome plilzay dilzzouble dilzutch!
Hilzzoo?
My gizzirl!
Brillzing her izzin!
Izzo kizzay!
Izzall rizzight...
Izzo kizzay!
Izzall rizzight! Nizzow wizzee wilzzo-izzo-zee!
[Bridge: Missy]
I don't go out my house shorty
You just waiting to see
Who gon' roll up in the club and then report that next week
Just wanna see who I am fucking boy
Sniffing some coke
I know by the time I finish this line Imma hear this on the radio
[Verse 3: Ludacris]
Yeah, uh huh, okay
Once upon a time in College Park
Where they live life fast and they scared of dark
There was a little nigga by the name of Chris
Nobody paid him any mind
No one gave a shit
Knowing he could rap
No one lifted hands
So he went about his business and devised a plan
Made a CD and then he hit the block
50 thousand sold
Seven dollars a pop
Hold the phone
Three years later
Stepped out the swamp
With ten and a half gators
Now all around the world on the microphone
He leave the booth smelling like Burberry cologne
Still riding chrome
Got bitches in the kitchen
Never home alone
And he's on the grind
Please let me know if he's on your mind
And respect you'll give me
Ludacris I live loud just like Timmy
Fuck, have to clear these rumors
I got a headache and it's not a tumor
Get up on my lap and get my head sucked tight
Sprayed so I never let the bed bugs bite
Hard to the core
Core to the rotten
Jump down, turn around, pick a bale of cotton
Yahh
[Chorus]
Millze cillzan sillzome plilzay dilzzouble dilzutch!
Hilzzoo?
My gizzirl!
Brillzing her izzin!
Izzo kizzay!
Izzall rizzight...
Izzo kizzay!
Izzall rizzight! Nizzow wizzee wilzzo-izzo-zee!
[People in the background chatting]
Yo, straight up Missy killed that shit tonight for real
I know I know, I don't even care about her being preganant by Michael Jackson
You know what we should do
We should go get her album when it comes out
There she go, there she go, there she
Heeeey Misssy
[Missy]
Hi Missy?
What's up fools?
You think I ain't knowin y'all broke, Milli Vanilli
J.J. Fad wannabes ain't over here gossiping bout me?
Yo how bout you buff these Pumas for 20 cents
So your lights won't get cut off
You soggy breasts, cow stomachs
Yo take those baby GAP shirts off, too
You just mad cuz Payless ran outa plastic pumps for the after party
Yo by the way, go get my album
Damn!
[Chorus/Outro]
Millze cillzan sillzome plilzay dilzzouble dilzutch!
Hilzzoo?
My gizzirl!
Brillzing her izzin!--(Echos)
[Intro: Missy Elliott & Timbaland]
[*Yawning*]
Run the track
[Chorus: Missy Elliott & Ann Peebles]
Me I'm super fly, super dupa fly
(I can't stand the rain) Supa dupa fly
Me I'm super fly, (against my window) super dupa fly
(I can't stand the rain) supa dupa fly
Me I'm super fly, (against my window) super dupa fly
(I can't stand the rain) supa dupa fly
Me I'm super fly, (against my window)
[Verse 1: Missy Elliott]
When the rain hits my window
I take and *cough* me some indo
Me and Timbaland, ooh, we sang a jangle
We so tight that you get our styles tangled
Sway on dosie-do like you loco
Can we get kinky tonight?
Like Coko, so-so
You don't wanna play with my Yo-Yo
I smoke my hydro on the D-low (D-D-D-D-D-low)
[Hook: Ann Peebles]
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain
[Verse 2: Missy Elliott]
Beep, beep, who got the keys to the Jeep, vroom
I'm driving to the beach
Top down, loud sounds, see my peeps
Give them pounds, now look who it be
It be me, me, me and Timothy
Look like it's 'bout to rain, what a shame
I got the Armor-All to shine up the stain
Oh, Missy, try to maintain
Icky-icky-icky-icky-icky-icky-icky
[Hook: Ann Peebles]
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain
[Verse 3: Missy Elliott & Ann Peebles]
I feel the wind
5, 6, 7, 8, 9, 10
9, 10
Begin, I sit on Hills like Lauryn
Until the rain starts coming down, pouring
Chill, I got my umbrella
My finger waves these days, they fall like Humpty
Chumpy, I break up with him before he dump me
To have me, (I can't stand the rain), yes, you lucky (against my window)
[Outro: Ann Peebles]
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain
I can't stand the rain
I can't stand the rain
I can't stand the rain
I can't stand the rain against my window
I can't stand the rain against my window
I I can't stand the rain against my window
I can't stand the rain against my window
I can't stand the rain
I can't stand the rain
I can't stand the rain
I can't stand the rain
34.4 Get Specific Song and Lyrics By a Specific Artist
To get the song lyrics from a specific artist, you can use the method .search_song()
= LyricsGenius.search_song("Missy Elliott", "Work It") song
Searching for "Missy Elliott" by Work It...
Done.
song.lyrics
"[Intro]\nDJ, please pick up your phone, I'm on the request line\nThis is a Missy Elliott one-time exclusive, come on\n\n[Chorus]\nIs it worth it? Let me work it\nI put my thing down, flip it and reverse it\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nIf you got a big *elephant trumpet*, let me search ya\nAnd find out how hard I gotta work ya\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nC'mon\n\n[Verse 1]\nI'd like to get to know ya so I could show ya\nPut the pussy on ya like I told ya\nGive me all your numbers so I can phone ya\nYour girl acting stank, then call me over\nNot on the bed, lay me on your sofa\nCall before you come, I need to shave my chocha\nYou do or you don't or you will or won't ya?\nGo downtown and eat it like a vulture\nSee my hips and my tips, don't ya?\nSee my ass and my lips, don't ya?\nLost a few pounds and my waist for ya\nThis the kinda beat that go ra-ta-ta\nRa-ta-ta-ta-ta-ta-ta-ta-ta-ta\nSex me so good I say blah-blah-blah\nWork it, I need a glass of water\nBoy, oh boy, it's good to know ya\nC'mon\n\n[Chorus]\nIs it worth it? Let me work it\nI put my thing down, flip it and reverse it\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nIf you got a big *elephant trumpet*, let me search ya\nAnd find out how hard I gotta work ya\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nC'mon\n\n[Verse 2]\nIf you a fly gal, get your nails done\nGet a pedicure, get your hair did\nBoy, lift it up, let's make a toast-a\nLet's get drunk, that's gonna bring us closer\nDon't I look like a Halle Berry poster?\nSee the Belvedere playing tricks on ya\nGirlfriend wanna be like me, never\nYou won't find a bitch that's even better\nI make you hot as Las Vegas weather\nListen up close while I take it backwards\n\u200bsdrawkcab ti ekat ot ekil yssiM yaw eht hctaW\nI'm not a prostitute, but I could give you what you want\nI love your braids and your mouth full of fronts\nLove the way my ass go bum-bum-bum-bum\nKeep your eyes on my bum-bum-bum-bum-bum\nYou think you can handle this badonka-donk-donk\nTake my thong off and my ass go boom\nCut the lights on so you see what I could do\nC'mon\n\n[Chorus]\nIs it worth it? Let me work it\nI put my thing down, flip it and reverse it\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nIf you got a big *elephant trumpet*, let me search ya\nAnd find out how hard I gotta work ya\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nC'mon\n\n[Verse 3]\nBoys, boys, all type of boys\nBlack, White, Puerto Rican, Chinese boys (C'mon)\nWhy-thai, thai-o-toy-o-thai-thai\nRock-thai, thai-o-toy-o-thai-thai (C'mon)\nGirls, girls, get that cash\nIf it's 9 to 5 or shaking your ass (Aha)\nAin't no shame, ladies do your thing (C'mon)\nJust make sure you ahead of the game\nJust 'cause I got a lot of fame super\nPrince couldn't get me change my name, papa\nKunta Kinte a slave again, no sir\nPicture blacks saying, “Oh yes'a, massa”\nPicture Lil' Kim dating a pastor\nMinute Man and Big Red could outlast ya\nWho is the best? I don't have to ask ya\nWhen I come out, you won't even matter\nWhy you act dumb like, uh, duh?\nSo you act dumb like, uh, duh\nAs the drummer boy go ba-rom-pop-pom-pom\nGive you some-some-some of this Cinnabun\nC'mon\n\n[Chorus]\nIs it worth it? Let me work it\nI put my thing down, flip it and reverse it\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nIf you got a big *elephant trumpet*, let me search ya\nAnd find out how hard I gotta work ya\nTi esrever dna ti pilf, nwod gniht ym tup\nTi esrever dna ti pilf, nwod gniht ym tup\nC'mon\n\n[Outro]\nTo my fellas (Ooh good god!)\nI like the way you work that (Uh huh, la-la-la-la)\nTo my ladies (Whoo! Good god!)\nYou sure know how to work that\n\nYeah, it's Missy Elliott!\nI hope y'all enjoying what y'all heard so far\nI was sittin' here thinkin' like\nBig Daddy Kane and Public Enemy\nSalt n Pepa, Lyte, EPMD, LL, Run-DMC\nKRS-One, Rakim\nMost of them artists used to dance\nAnd still get respected in the street\nDon't be scared to Bankhead or Bogo\nOr move as far as sold Michael Jackson 43 million\nShoot, errbody have the zipper jacket\nAnd half of these thugs have the glove to match, ya feel me?\nYo, it's ok though, if you wanna be hard and ice grill\nAnd Harlem Shake at the same time, whatever\nLet's just have fun, it's hip-hop man, this is hip-hop!"
34.5 Save Lyrics to .txt File
='txt') song.save_lyrics(extension
Wrote Work It to lyrics_missyelliott_workit.txt.
34.6 Get Songs and Lyrics For a Specific Album
As you can see, LyricsGenius is an extremely useful Python package! But one thing that we can’t do with LyricsGenius is get all the song lyrics for a particular album.
So we’re going to use the web scraping functions that we wrote in the last lesson to get all the song titles for a specific album, then use LyricsGenius to get the lyrics for each of those songs, and then save them all as text files in a directory.
Import necessary Python libraries
from bs4 import BeautifulSoup
import re
import lyricsgenius
import requests
from pathlib import Path
Make RegEx Function To Clean Up Songs
def clean_up(song_title):
if "Ft" in song_title:
= re.compile(".*(?=\(Ft)")
before_ft_pattern = before_ft_pattern.search(song_title).group(0)
song_title_before_ft = song_title_before_ft.strip()
clean_song_title = clean_song_title.replace("/", "-")
clean_song_title
else:
= song_title.replace("Lyrics", "")
song_title_no_lyrics = song_title_no_lyrics.strip()
clean_song_title = clean_song_title.replace("/", "-")
clean_song_title
return clean_song_title
Make Function To Scrape Song Titles For Album
def get_all_songs_from_album(artist, album_name):
= artist.replace(" ", "-")
artist = album_name.replace(" ", "-")
album_name
= requests.get(f"https://genius.com/albums/{artist}/{album_name}")
response = response.text
html_string = BeautifulSoup(html_string, "html.parser")
document = document.find_all("h3", attrs={"class": "chart_row-content-title"})
song_title_tags = [song_title.text for song_title in song_title_tags]
song_titles
= []
clean_songs for song_title in song_titles:
= clean_up(song_title)
clean_song
clean_songs.append(clean_song)
return clean_songs
Make Function To Download Lyrics For All Songs in Album
def download_album_lyrics(artist, album_name):
# Set up LyricsGenius with your Genius API client access token
#client_access_token = Your-Client-Access-Token
= lyricsgenius.Genius(client_access_token)
LyricsGenius = True
LyricsGenius.remove_section_headers
# With the function that we previously created, go to Genius.com and get all song titles for a particular artist's album
= get_all_songs_from_album(artist, album_name)
clean_songs
for song in clean_songs:
#For each song in the list, search for that song with LyricsGenius
= LyricsGenius.search_song(song, artist)
song_object
#If the song is not empty
if song_object != None:
#Do some cleaning and prep for the filename of the song
= artist.replace(" ", "-")
artist_title = album_name.replace(" ", "-")
album_title = song.replace("/", "-")
song_title = song.replace(" ", "-")
song_title
#Establish the filename for each song inside a directory that begins with the artist's name and album title
=f"{artist_title}_{album_title}/{song_title}"
custom_filename
#A line of code that we need to create a directory
#os.makedirs(os.path.dirname(filename), exist_ok=True)
f"{artist_title}_{album_title}").mkdir(parents=True, exist_ok=True)
Path(
#Save the lyrics for the song as a text file
=custom_filename, extension='txt', sanitize=False)
song_object.save_lyrics(filename
#If the song doesn't contain lyrics
else:
print('No lyrics')
Call the function
"Missy Elliott", "Under Construction") download_album_lyrics(
Searching for "Intro-Go To The Floor" by Missy Elliott...
Done.
Wrote Intro/Go To The Floor to Missy-Elliott_Under-Construction/Intro-Go-To-The-Floor.txt.
Searching for "Bring the Pain" by Missy Elliott...
Done.
Wrote Bring the Pain to Missy-Elliott_Under-Construction/Bring-the-Pain.txt.
Searching for "Gossip Folks" by Missy Elliott...
Done.
Wrote Gossip Folks to Missy-Elliott_Under-Construction/Gossip-Folks.txt.
Searching for "Work It" by Missy Elliott...
Done.
Wrote Work It to Missy-Elliott_Under-Construction/Work-It.txt.
Searching for "Back in the Day" by Missy Elliott...
Done.
Wrote Back in the Day to Missy-Elliott_Under-Construction/Back-in-the-Day.txt.
Searching for "Funky Fresh Dressed" by Missy Elliott...
Done.
Wrote Funky Fresh Dressed to Missy-Elliott_Under-Construction/Funky-Fresh-Dressed.txt.
Searching for "Pussycat" by Missy Elliott...
Done.
Wrote Pussycat to Missy-Elliott_Under-Construction/Pussycat.txt.
Searching for "Nothing Out There for Me" by Missy Elliott...
Done.
Wrote Nothing Out There for Me to Missy-Elliott_Under-Construction/Nothing-Out-There-for-Me.txt.
Searching for "Slide" by Missy Elliott...
Done.
Wrote Slide to Missy-Elliott_Under-Construction/Slide.txt.
Searching for "Play That Beat" by Missy Elliott...
Done.
Wrote Play That Beat to Missy-Elliott_Under-Construction/Play-That-Beat.txt.
Searching for "Ain't That Funny" by Missy Elliott...
Done.
Wrote Ain’t That Funny to Missy-Elliott_Under-Construction/Ain't-That-Funny.txt.
Searching for "Hot" by Missy Elliott...
Done.
Wrote Hot to Missy-Elliott_Under-Construction/Hot.txt.
Searching for "Can You Hear Me" by Missy Elliott...
Done.
Wrote Can You Hear Me to Missy-Elliott_Under-Construction/Can-You-Hear-Me.txt.
Searching for "Work It (Remix)" by Missy Elliott...
Done.
Wrote Work It (Remix) to Missy-Elliott_Under-Construction/Work-It-(Remix).txt.
Searching for "Drop the Bomb" by Missy Elliott...
Done.
Wrote Drop the Bomb to Missy-Elliott_Under-Construction/Drop-the-Bomb.txt.
If there is anything wrong, please open an issue on GitHub or email f.pianzola@rug.nl