Play or download YouTube videos from the terminal
Click to navigate.
$PATH
and make it executable.usage: yt.py [-h] [-u] [-v] [-d] [-n NUM] [-o DIR] [SEARCH_STRING ...]
Play YouTube media without API
positional arguments:
SEARCH_STRING media to play
options:
-h, --help show this help message and exit
-u, --url display URL instead of playing
-v, --video play video instead of music
-d, --download download media instead of playing
-n NUM, --num NUM nth result to play or download
-o DIR, --output DIR folder to save downloaded media
List of mpv hotkeys: https://defkey.com/mpv-media-player-shortcuts
Stream audio:
yt.py gurenge band cover
Download audio:
yt.py -d astronomia
Watch a video:
yt.py -v rickroll
Download a video:
yt.py -dv penguin flock
Play the audio of the second search result:
yt.py -n 2 plastic love daft punk
Download a video to a directory other than $HOME/Videos
(default location):
yt.py -do "$HOME/Music/" darude sandstorm
PS: Here’s a list of mpv keyboard shortcuts for your convenience.
.pyx
fileI’m currently not updating it anymore. Please consider using the .py
file instead
Cython is supposed to be faster but I don’t really know Cython so I couldn’t optimize it as well. If you can do so, feel free to make a fork, and maybe even a pull request so the script can be improved. It’ll be a learning experience for me as well.
As for the performance… It may be slightly faster but the program is still network-bound. Which means, faster internet = faster query = media is played sooner.
Compile an executable file using this shell script if you want.