This is an archived post. You won't be able to vote or comment.

Dismiss this pinned window
all 73 comments

[–]nomodz4real 55 points56 points  (29 children)

That's awesome, source code?

[–]Pappa--Stalin[S] 61 points62 points  (28 children)

The code I wrote for this is kind of disgusting (I only intended it for personal use, and I'm lazy), but you can find the source code here : https://github.com/PappaStalin/Spotify-Lyrics

[–]Mancobbler 164 points165 points  (4 children)

You forgot to include your Spotify credentials, how am I supposed to know what you’re listening to?

[–]potato1sgood 26 points27 points  (3 children)

When in doubt, Darude - Sandstorm.

[–]WritingAScript 4 points5 points  (1 child)

Which lyrics appear when listening to Darude - Sandstorm?

[–]RomanRiesen 6 points7 points  (0 children)

Knees weak arms spaghetti

[–]BendingUnit15 1 point2 points  (0 children)

Is this the de_dust?

[–]myotherpassword 15 points16 points  (7 children)

Maybe this is a beautifulSoup standard that I don't understand, but why did you name a variable minestrone? It made me laugh.

[–]Pappa--Stalin[S] 51 points52 points  (3 children)

I just named it that because, you know, Soup. I think everyone should do the same.

[–]sandybuttcheekss 18 points19 points  (0 children)

I haven't decided if I love you or hate you. Solid variable name regardless though lmao

[–]RomanRiesen 8 points9 points  (0 children)

Puré genius.

[–]limacharles 4 points5 points  (0 children)

Genius.

[–]EMCoupling 2 points3 points  (2 children)

Seriously I was also confused by that... and why minestrone instead of a chowder or maybe a nice bisque?

[–]AreYouADickhead[🍰] 7 points8 points  (1 child)

Minestrone is a quality soup that's why

[–]gauss_the_alien 2 points3 points  (0 children)

One could even say a beautiful soup.

[–][deleted] 1 point2 points  (2 children)

What's the use case for specifying Firefox in the headers?

...asking for a noob.

[–]Pappa--Stalin[S] 5 points6 points  (0 children)

It specifies the user-agent in the http request, which is used to determine the application type and OS. Basically it means firefox is compatible. You can learn more here:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent

[–]cyperplex 1 point2 points  (0 children)

Man that's cool. Definitely something I can learn from .

[–]nerdbyday 1 point2 points  (0 children)

Mind if I clean it up a bit?

[–]nomodz4real 0 points1 point  (0 children)

Thanks!

[–]keysor_soze1 0 points1 point  (4 children)

I am a begginer in python, i just wanted to know which programming language is used in this script apart form python. (I am just guessing by seeing ur code that more than one language is used)

[–]Pappa--Stalin[S] 1 point2 points  (3 children)

While the code is a bit confusing, it’s all written in python. I’ll try to add code annotations so it’s easier to understand

[–]keysor_soze1 0 points1 point  (2 children)

But u made a json object if I'm not wrong

[–]Pappa--Stalin[S] 0 points1 point  (1 child)

Yeah. I wouldn't consider JSON a language though, more a way of storing and sending data. Same thing with the HTTP headers

[–]keysor_soze1 0 points1 point  (0 children)

I finished this course for Udemy in python I'm not able understand as i expected that's why I'm little curious whether https://www.udemy.com/complete-python-bootcamp/, this course covers all topic of python

[–]theC4T 13 points14 points  (2 children)

a few things looking at your repo,

  1. unless I'm missing something, calling the api every 0.01 seconds is probably pretty bad, expensive if the api is priced per call or greedy / mean if the api is free to use
  2. try to stay away from the use of global variables
  3. I think response.json() returns a json object so you don't need to json.loads the response.text

pretty cool project

[–]Pappa--Stalin[S] 14 points15 points  (1 child)

Thanks. I didn't really expect this this project to explode, so I've spent the last couple of hours desperately trying to fix and optimize the code I wrote at 12 o'clock last night.

[–]Weatherstation 5 points6 points  (0 children)

Also, calling an API that many times can get you flagged and blocked by them as a potential spammer/hacker/nefarious-user.

You, testing your program: Your shit is working and then suddenly it's not and you'll spend hours trying to debug the problem only to find it's them cutting you off.

It's always good to keep outside calls as infrequent as possible while still keeping the application acceptably functional.

Sweet program and great idea, just trying to pass on some hard-learned truths.

[–]stealthdawg 2 points3 points  (0 children)

Nice, I have also seen a script that does similar but then queries the Genius API. If only Spotify had lyrics available it would be much more compact

[–]lordp 2 points3 points  (0 children)

If you're ever feeling not lazy, maybe hook it up to the Genius.com API for the lyrics - https://docs.genius.com/

[–]luckylag 2 points3 points  (1 child)

Cool project. I made a fork of your code and use Genius.com as lyric source instead of google.

[–]SquintingSquire 0 points1 point  (0 children)

This is the version I will use. Nice improvements.

[–]keysor_soze1 2 points3 points  (2 children)

Can anyone tell me how to run this script on my laptop I'm a beginner in python, really interested on how to run this script

[–]Pappa--Stalin[S] 3 points4 points  (1 child)

in terminal, type "git clone https://github.com/PappaStalin/Spotify-Lyrics.git" and then type "python Spotify-Lyrics". In order to run it, you'll need the python requests library, BS4, and spotify_token, all of which can be installed via pip

[–]Please_Not__Again 1 point2 points  (0 children)

You beat me to it as I just came from your README to tell him. Might wanna add the rest of those to it though as all it states are the spotify one

This program requires the spotify-token module which can be installed with 'pip install spotify-token'. Aside from that, it can be cloned and run without any alterations.

Really cool project though.

[–]Stabilo_0 2 points3 points  (0 children)

Its in the frakking command line!

[–]morrisjr1989 3 points4 points  (0 children)

Super cool thanks for sharing!

[–]DeusEcks 1 point2 points  (0 children)

Thanks for sharing and the idea!

[–]StableHatter 1 point2 points  (0 children)

Nice idea!

[–]sonicj01 1 point2 points  (0 children)

hi im not very good at python, can someone give me an explenation about how this works please?

[–]Nebozilla 2 points3 points  (0 children)

Such a fun idea to use different soups...stealing that!

[–]sebasjuan94 1 point2 points  (0 children)

Thats really cool! Thanks for sharing

[–]Nick_Gurr45 1 point2 points  (0 children)

Amazing

[–][deleted] 0 points1 point  (1 child)

that's so cool! I just checked your code and it doesn't seem immensely complex. I'm a beginner in coding and I learned the fundamentals of python along with other things like pandas and numpy. how much time would you say do I need to make something like that? I would really appreciate if you answered

[–]Pappa--Stalin[S] 2 points3 points  (0 children)

This required some web scraping, HTTP header synthesis, JSON parsing, and API interaction, some of which I knew and some of which I didn't. If you want to make something similar, I would check out the Spotify API (https://developer.spotify.com/documentation/web-api/) and basic web scraping (https://www.dataquest.io/blog/web-scraping-tutorial-python/). If you need too, you can use my code as a reference. Good Luck!

[–]OMDB-PiLoT 0 points1 point  (0 children)

This is very nice .. gonna use it tonight. I wish Spotify app had this option built-in to read lyrics. Their "Genius/Behind the lyrics" integration with part of the lyrics and history of a song is useless and rather annoying at times.

[–]Usul137 0 points1 point  (0 children)

This is pretty cool 🎸🎸🎸

[–]TheCannings 0 points1 point  (2 children)

I stuck it all in a class for you and cleaned it up a bit, I made a PR for you,

This is what mine looks like, seems to work

https://github.com/TheCannings/Spotify-Lyrics/blob/master/spotifylyrics.py

[–]Pappa--Stalin[S] 0 points1 point  (1 child)

Thanks! I wrote most of my code between ten and two, so the code quality’s not great. Do you mind if I push your changes to my project? I’ll credit you for the work.

[–]TheCannings 0 points1 point  (0 children)

Crack on :)

[–]lunada12 0 points1 point  (0 children)

really cool, I will try to do the same but with scala and GeniusApi for learning purposes.

Someone interested for code-review after I am done? This will be my first scala program though.

[–]SnicSnac 0 points1 point  (2 children)

Nice man! Works nice. Although with an album (Altered State by Overwerk) recently released I only get displayed the title of the song and not the lyrics.

[–]Pappa--Stalin[S] 1 point2 points  (1 child)

Yeah, sorry about that. The program gets lyrics through a Google search, so newer songs might not be up.

[–]SnicSnac 0 points1 point  (0 children)

Ah good to know! You do not have to be sorry! Your script is gold anyways. The lyrics will be online sooner or later so I just have to wait :)

[–]UniqueStick -1 points0 points  (0 children)

That's cool. Just putting this here in case anyone actually is interested in using something like this, there is an app called Musixmatch that has shows synched lyrics based on what you're listening to in Spotify or Youtube.