DEV Community

Cover image for I created a command line tool to download high quality music
Soham
Soham

Posted on • Edited on

I created a command line tool to download high quality music

I already created a post regarding this, but I did not get as many views as I expected. This got me wondering, where did I go wrong... And then I realized, the post was literally so dry ._.

So today I am trying to write a nice blog post, as well as share how I ended up creating what I created. "Killing two birds with one stone"...?

What did I create?

What I created is, personally something which I really really love to use. A command line tool to download high quality music:

spot-dl - npm

Downloads music from YouTube and applies Spotify metadata (premium free of cost). Latest version: 3.1.3, last published: a year ago. Start using spot-dl in your project by running `npm i spot-dl`. There are no other projects in the npm registry using spot-dl.

favicon npmjs.com

I love this tool very very much. The music it downloads is of very good quality, and whenever I use it I get that feeling of pride, like "yeah I made this and it works so well".

Although I create a lot of stuff for my friends to enjoy, this was just step 1, because now I can convert it to a module and then from that a website to download the music, still thinking about it though.

Why I created it

Back in like November or December 2021, my family and I were going to our hometown for an occasion I don't remember. Now my parents chat all the time in the car, my sister has got mobile data for Amazon Music or Spotify. And I'm left all alone... No music, chit-chats nothing. I kept asking my dad for mobile data but he kept saying no.

How I created it

I started googling how to download songs from Spotify for free. And just as you thought, no the search results weren't helpful. Now during this time, I was learning a course on Udemy (still am) about web development. A little bit of frontend, backend, REST all that good stuff.

So my next search result was a little bit better than the last one, "how to download music using spotify api". Now this is where I started getting search results related to programming. In the course JavaScript was the only language being used. Therefore me being desperate, went for JavaScript straight up.

I had made a Discord bot to stream music in a voice channel. The bot would use youtube-sr to run a search query, and ytdl-core would download the audio and stream. Pretty simple right?

But the problem arose for downloading music with the metadata, as YouTube audio obviously does not have metadata. This is where spotify-web-api-node comes in. To simply get the metadata, not the audio just the metadata (audio isn't for free obviously).

So the logic would go like:

  • Get metadata from Spotify URL
  • Run YouTube search query with title retrieved from metadata
  • Download audio
  • Apply metadata
  • Save the file as .mp3

I started programming, drank coffee, debugged a lot, had fun and listen to music while doing it, and done, spot-dl existed.

What I learned

I am still a newbie in web development. I have 2 years of experience in game development at Roblox (Lua and free-lancing). And although it was nothing very serious, I learnt a lot about programming in general.

While making this project, I learned a lot about just JavaScript in itself. The code I wrote, wasn't the best quality it could have been better. These 3 topics in particular though:

  • Promises
  • File system
  • Command line arguments

And also this blog post, I have literally no experience in writing stuff like this online. I just started typing and it went well I think... Dividing the blog post in separate sections.

Keeping it casual, I think being too serious makes it look like you're gonna explode any minute, which doesn't mean you shouldn't be serious but just not too damn serious you know. Don't stress it out...

I am still 15 and have a lot to learn, so I would really appreciate feedback, thanks for reading!!

Top comments (1)

Collapse
 
howarddo2208 profile image
HowardDo2208

Good job brother, just 15 and you can do this is quite remarkable. I'll give it a try and a star