Home Linux Commandline Tools mps-youtube – A Terminal Based YouTube Player and Downloader

mps-youtube – A Terminal Based YouTube Player and Downloader

Ever felt like wanting to complete most of your Linux computing tasks from the command-line environment without having to navigate to and from the GUI (Graphical User Interface)? A Linux operating system is an endless maze of rich computing knowledge and experience.

Most of the Linux materials either have technical documentation or none. Sometimes we might find the appropriate documentation that meets the objective we want to accomplish under a Linux environment but end up taking too much time consuming and implementing the retrieved material data.

The YouTube platform provides an easier way of understanding a Linux computing concept since video files are easier and faster to consume than documentation files.

[ You might also like: ytfzf – Find and Watch YouTube Videos in Linux Terminal ]

Therefore, if you are interested in learning how to implement a Linux application package for playing and downloading your favorite YouTube videos from the Linux terminal, this article guide is for you.

mps-youtube Features

The mps-youtube application is an mps-based project that is effective in searching, streaming, and downloading YouTube-based video and audio files. This program perfectly interfaces with the YouTube platform as a result of the pafy library.

We can summarize the mps-youtube program features with the following bullet points:

  • Requires Python 3.x, player, or mpv.
  • Supports view of video comments.
  • Supports download of audio and video files.
  • With ffmpeg or avconv installed, users can convert video files to mp3 files.
  • Users can create and save local playlists.
  • YouTube playlists can be searched and imported.
  • Album tracks can be searched via respective album titles.
  • YouTube audio/video files can be searched and played.

Installing mps-youtube in Linux

To install mps-youtube, run the following command depending on the Linux distribution you are using.

$ sudo apt install mps-youtube         [On Debian, Ubuntu and Mint]
$ sudo pacman -S mps-youtube           [On Arch Linux]
$ sudo zypper install mps-youtube      [On OpenSUSE]    

Once installed, you can start the mps-youtube using the following command on your terminal.

$ mpsyt
mps-youtube Player
mps-youtube Player

To search for a video file with a key phrase like “nginx explained”, we would implement it in the following manner:

/nginx explained

If you run into “Youtube Error 403”, consider setting your own Google API key.

Error fetching data. Possible network issue.
Youtube Error 403: The request cannot be completed because you have exceeded your quota.

Quit mps-youtube.

> q

Create Google API Key for mps-youtube Tool

Firstly, create a Google developers account and then create a Google project of your choice from the CREATE PROJECT button after highlighting/selecting the No organization (or organization name if you have one).

Create Google Project
Create Google Project

Give your project a name, and the location * field should be automatically populated.

Set Google Project Name
Set Google Project Name

Select your project and go to GoogleAPIs library, scroll down and click on YouTube Data API v3.

Choose YouTube Data API
Choose YouTube Data API

Ensure you have selected your project before clicking ENABLE to activate the API.

Enable YouTube Data API
Enable YouTube Data API

Click on CREDENTIALS and then CREATE CREDENTIALS.

Create Credentials
Create Credentials

Click on API KEY and copy the generated API key and save it somewhere.

Google API Key
Google API Key

Get rid of the mps-youtube cache file:

$ rm ~/.config/mps-youtube/cache_py_*

Implement the new API key into mps-youtube:

$ mpsyt set api_key YOUR_KEY_HERE

It should lead to the following interface:

List Google API Key
List Google API Key

Quit the mps-youtube app.

> q

Open the file:

$ nano $HOME/.local/lib/python3.10/site-packages/pafy/backend_youtube_dl.py

Comment out the line…

self._dislikes = self._ydl_info['dislike_count']

and replace it with the line.

self._dislikes = self._ydl_info.get('dislike_count', 0)
Configure Youtube-dl
Configure Youtube-dl

Save and close the file.

Search and Download YouTube Video in Linux Command Line

Now start the mps-youtube and re-attempt our “nginx explained” search.

Search Youtube Videos from Linux Terminal
Search Youtube Videos from Linux Terminal

To play item number 1, key in:

1

To download a video, use d <video number>, for example:

d 4

You will be redirected to another window to choose another item number based on the video/audio file size and quality you wish to download.

Download Youtube Videos from Linux Terminal
Download Youtube Videos from Linux Terminal

If the media file you choose has no audio, you will be allowed to choose one.

Download Youtube Audio from Linux Terminal
Download Youtube Audio from Linux Terminal

To view video information on video number 5:

i 5

More command usage on mps-youtube can be found by running the command:

$ mpsyt -h

We can now play and download video and audio files from the Linux terminal using the mps-youtube player.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.