Click to navigate.
- Python 3 (tested on PyPy 3.7.9 and CPython 3.9.1)
- mpv
- youtube-dl
- ffmpeg
- Download the file from the Releases page: ytplay
- Place it in your
$PATHand make it executable. - Enjoy!
Usage: ytpy [OPTIONS] <search query>
OPTIONS:
-h Show this help text
-d <search query> Download video
-v <search query> Play video (audio-only if not specified)
-u <search query> Fetch video URL
List of mpv hotkeys: https://defkey.com/mpv-media-player-shortcuts
-
Stream audio:
ytpy gurenge band cover -
Watch a video:
ytpy -v rickroll -
Download a video:
ytpy -d penguin flock -
Play the audio of the second search result:
YT_NUM=2 ytpy plastic love daft punk -
Download a video to a directory other than
$HOME/Videos(default location):YT_DLOAD_DIR=$HOME/Downloads/ ytpy -d darude sandstorm
PS: Here's a list of mpv keyboard shortcuts for your convenience.
- pystardust's ytfzf
- This article I found during my quest to implement a simplified version of ytfzf in Python3
About the .pyx file...
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.
