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.

smrdo_prdo
  • 509
  • 1
  • 5
  • 14

2 Answers2

5

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>
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.

grochmal
  • 8,657
  • 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
  • 1
    This does not work for playlists. – SuperSandro2000 Aug 15 '20 at 07:41