Skip to content

YouTube Music Player with MPV: A Terminal Dwellers's Dream Come True!

Greetings, fellow coders and music aficionados! Today, I'm ecstatic to unveil a project that's the culmination of my love for music, coding, and the ever-reliable terminal: the YouTube Music Player with MPV.

Screenshot from 2023-10-08 23-23-10

The Origin Story

Every coder has their unique environment setup — that perfect blend of tools, themes, and configurations that make the coding experience just right. For many of us, music is an integral part of this setup. It fuels our creativity, keeps us focused, and sometimes, it's the gentle nudge that pushes us through those challenging debugging sessions.

Being a subscriber to YouTube Music, I've always enjoyed the vast library it offers. But there was a hitch. While I spent most of my time in the terminal, crafting code, running commands, and managing projects, I had to constantly switch to a GUI app or a browser tab to control my music. It was a minor inconvenience, but as we all know, it's the little things that matter.

I yearned for a solution that would let me control my music right from the terminal, without any GUI distractions. And thus, the idea for the YTMusic Player with MPV was born.

The Nuts and Bolts

First and foremost, a massive shout out to the creators of the YTMusicAPI. This project would have remained a mere dream without their incredible API. To the entire team behind YTMusicAPI, thank you for your invaluable contribution to the community.

The YTMusic Player with MPV, at its essence, is a Python script tailored for terminal enthusiasts. You input a song or artist's name, and within moments, your chosen track fills the room. But how does this magic happen?

  1. YTMusicAPI Integration: Once you input your song or artist's name, the script taps into YTMusicAPI to fetch the relevant song details from YouTube Music.
  2. MPV Playback: With the song URL in hand, we delegate the playback duties to MPV, a versatile media player known for its wide range of features and robust performance.
  3. A Splash of Colour: To make the terminal experience even more delightful, we've incorporated coloured song titles. It's a small touch, but it adds a dash of vibrancy to the command line.

Global Keys: The Game-Changer

One of the standout features of this tool is the integration of global keys. This means that even when the script runs in the background, you can effortlessly control your music. Whether it's pausing a track, skipping to the next one, or adjusting the volume, you can do it all without ever leaving your coding environment. It's seamless, intuitive, and perfect for those who, like me, prefer to stay rooted in the terminal.

Compatibility and Testing

I've rigorously tested the YTMusic Player with MPV on Ubuntu 22, ensuring that it runs smoothly and efficiently. While the current version is tailored for terminal use, who knows? A GUI version might be on the horizon!

In Conclusion

For all the terminal lovers out there, I believe the YTMusic Player with MPV will be a delightful addition to your toolkit. It's been designed with you in mind, ensuring that your music and coding flow remains uninterrupted.

I invite you to try it out, share your feedback, and perhaps even contribute to its evolution. After all, the beauty of the open-source community lies in collaboration and continuous improvement.

So, here's to coding to the rhythm of our favourite tunes, right from the terminal. Happy coding and even happier listening! 🎵🎧🖥️