Run this:
hash youtube-dl 2>/dev/null || brew install youtube-dl; hash mpv 2>/dev/null || brew cask install mpv; echo -e '#!/bin/bash\nexec youtube-dl -o - "$@" | mpv --fs -' > ytp && chmod u+x ytp
It installs:
- youtube-dl
- mpv
- creates a script, called
ytp
in your current dir and makes it user executable.
Then you can watch any YouTube videos (or most of these) from your terminal (but not IN your terminal).
./ytp "https://www.youtube.com/watch?v=7a5NyUITbyk"
NOTE: the player plays in full-screen, because of the --fs
argument. Remove it, if you want to play in a window by default.
Move the ytp script to a dir in your path, so you don't have to invoke it from that creation dir via ./ytp ...
:
mv ./ytp /usr/local/bin/ytp
Then you can play from any dir:
ytp "https://www.youtube.com/watch?v=7a5NyUITbyk"