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