4

When playing just the audio from a youtube link, you have some thing like this:

mpv '<youtube_link>' --no-video

and when the song starts to play you have this on the terminal:

AO: [pulse] 44100Hz stereo 2ch float
A: 00:00:40 / 00:31:39 (2%) Cache: 10s+16498KB

or something similar.

Is there a way to display the link name (the name of the link being played)?

When you just play a normal video, the name is at the top of the window, and above the controls.

4

I have a script that I use just for exactly that purpose. It looks as follows:

#!/bin/sh
if [[ "x$1" == "x" ]]; then
  echo "Usage: mpvy <URL>"
else
  title=`youtube-dl --skip-download --get-title $1`
  mpv --no-video --term-playing-msg "### $title ###" $1
fi

If you are already using mpv to watch/listen to youtube clips then you should have youtube-dl installed since it is what mpv uses to download the youtube clip.

It is a little rough of a solution (e.g. does not work with several links at once) but serves its purpose. And can be easily extended using a for loop.

3
  • I have youtube-dl, that's why I put in the tag. Thanks the script! I have a question. I understand everything except the condition in the beginning. You are testing if the user has submitted a empty argument. Why is the x necessary? Couldn't you just check if it was an empty string?
    – smrdo_prdo
    Jul 26 '16 at 22:51
  • 1
    @smrdo_prdo - That x is just an old scripting habit. Some versions of ksh (and some other ancient shells) did not properly evaluate a condition against an empty string. That happened because they dropped the quotes before the comparison ending in [[ $1 == ]], which would be a syntax error.
    – grochmal
    Jul 26 '16 at 23:01
  • This does not work for playlists. Aug 15 '20 at 7:41
4

Method 1:

Add term-playing-msg="Title: ${media-title}" to your mpv.conf

Method 2:

Add --term-playing-msg='Title: ${media-title}' to your command

mpv --term-playing-msg='Title: ${media-title}' <YOUR_VIDEO_LINK>
2
  • 1
    This should be the accepted answer cause it works also with playlists. Aug 15 '20 at 7:40
  • This is a better solution than the one in the accepted answer. It works well with playlists and multiple files arguments, and it doesn't require a separate youtube-dl invocation just to get the file title.
    – Haile
    Aug 25 '20 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.