Ytfzf - search, watch or download YT from terminal

Originally published at: ytfzf - search, watch or download YT video from terminal - Mabox Linux notes

Ytfzf is a script that helps you find Youtube videos and opens/downloads using mpv/youtube-dl.

Features:

  • thumbnails
  • history support
  • download support
  • format selection (and default formats)
  • queue multiple tracks (using fzf multiselection)

Usage: ytfzf [OPTIONS] 
  OPTIONS:
     -h, --help                           Show this help text
     -t, --thumbnails                     Show thumbnails (requires ueberzug)
                                          Doesn't work with -H -D
     -D, --ext-menu                       Use external menu(default dmenu) instead of fzf
     -H, --choose-from-history            Choose from history
     -x, --clear-history                  Delete history
     -m, --audio-only   search-query    Audio only (for music)
     -d, --download     search-query    Download to current directory
     -f                 search-query    Show available formats before proceeding
     -a, --auto-play    search-query    Auto play the first result, no selector
     -r  --random-play  search-query    Auto play a random result, no selector
     -n, --video-count= video-count     To specify number of videos to select with -a or -r
     -l, --loop         search-query    Loop: prompt selector again after video ends
     -s                 search-query    After the video ends make another search
     -L, --link-only    search-query    Prints the selected URL only, helpful for scripting
  Use - instead of search-query for stdin

Examples

Watch to find videos (with out thumbnails)

ytfzf query

Watch to find videos with thumbnails

ytfzf -t query

You can use multiple options together, here are some examples

Steam audio (music), and prompt as the music finishes

ytfzf -ml query

Download a video from your history

ytfzf -dH

Open using dmenu in a certain format

ytfzf -fD  

If you started watching a video and you wish to change format then
first hit Q to save position and quit mpv, then choose your format using

ytfzf -faH

Useful mpv key bindings

* Use f for full screen
* Use J for subtitles (also works with audio, if the music video has subtitles)
* Use L for single-loop

Installation

 yay -S ytfzf ueberzug

More info on Github ytfzf project site

7 Likes

8 Likes

i have never try this , but kā€™now i have , and i find it very good in fact , it can handle alot of things .

for example:

ytfzf -t query accept , or acdc , or whatever you like wil just load the videoā€™s of that band , but i wonder can it handle more loads in a single search that 30 pieces :stuck_out_tongue_winking_eye: in other words is there a script of ytfzf that you can change things or not i dont see it in hidden folders only in .cache/ytfzf , but i wonder if you can change something or is it only from the commands that it can handle more search in one single command

1 Like

Very good . Best of all. NO ADS :slight_smile: Playing videos without any interruptions.

1 Like

Well if you want to play all the videos enlisted and found by ytfzz; letā€™s say you type adding -A in your query like this: ytfzf -t -A AC/DC ā€¦ it will play the whole visual list of tunes found onlineā€¦ it can be more 21 videos, all played one by one. I hope this can be of some help.

1 Like

Personal project: To get ytfzf watch all enlisted videos in the same resolution and quality.
Soon I am posting & sharing another Lua script for setting ytfzf (ytdlp) with preferred resolution & window sizing when using mpv player output. So anyone can set this manually inside the Lua script with their choices to get a streaming video resolution in 240, 360, 480, 720, 1080 or 1440. Mabox does not need extra packages to have it running, so it works out by default, provided that this Lua script is positioned inside: ~/mabox/.config/mpv/scripts folder ( just where you placed the previous Lua_notify mpv script) https://i.imgur.com/QNiP1Ew.png . If you look for MPV forum & tweak settings you can even position it always on the same area of your desktop ( this is not implemented in this Lua Script though). :shushing_face:

3 Likes

Iā€™ve been testing it and itā€™s very fast and useful but I have some problems that jump out at me

1 Like

Hey, thatā€™s great! Irrespective of this post I use YTFZF several weeks now on my 12y old, intel Atom, 1GB Ram Netbook mainly to hear music. So here is the way I myself use Ytfzf:

for example ā€˜only audioā€™ with more results:

ytfzf -tm --pages=3 AC/DC

gives you thumbnail (-t) and no video output (-m). You can raise the possible search results by adding the option --pages=n. 3 gives you already 59 results and is reasonably fast in a slow mobile network. 5 gives you 99 results. Try raising the number if you think your conduits can handle it!

Creating playlists:

ytfzf -t -I L -I R --pages=5 AC/DC > ytplst.list
Result:
AC/DC - Thunderstruck (Official Video)        |AC/DC  |4:53  |1204220890  |10 years ago  |https://youtube.com/watch?v=v2AC41dglnM
AC/DC - Shoot To Thrill (Iron Man 2 Version)  |AC/DC  |5:33  |171698161   |12 years ago  |https://youtube.com/watch?v=xRQnJyP77tY

ā€˜-I Lā€™ extracts the video-link, ā€˜-I Rā€™ extracts the video information (man ytfzf shows more options). You can play a file with youtube-links later with mpv or store it even for later download which i totally didnā€™t do :innocent: .

Browse youtube-playlists:

ytfzf -tm --scrape=youtube-playlist https://www.youtube.com/playlist?list=PLtyWuhGMhYaJiLtg3U2EarbbazBGMEzNs

They must be either public or non-listed to be able to get scraped. You also can scrape whole channels (see man page). You can search the results fzf-style with regex: ^sword - word at begin of line; 'word - exact match, use TAB for multiple selectā€¦

You may have noticed that original ā€˜ueberzugā€™ is not available anymore (git-repo erased) and forks might not work, or you use ytfzf in another distro that hasnā€™t ueberzug in the repos. MPV is also able to display thumbnails for ytfzf. Just create an alias in .bashrc or .bash_aliases file:

alias ytfzf='ytfzf --thumb-viewer=mpv'

I didnā€™t dive much more into it. I will definitely check out the LUA-script by @ben_chile , sounds exciting! I really would be glad if someone could tell me how to create a config file for ytfzf (should be in ~/.config/ytfzf but isnā€™t).

All in all a great program and people you show it think you are a 5* hacker. Also it introduced me to the marvels of fzf (such an awesome utility!!)

Cheers!

4 Likes

I really appreciate a lot that you shared part of your amazing ytfzfz tips & tweaks, dear @Faehnchen .
It really means a lot to all us big ā€œmelomaniacā€ fans. We love music so much indeed and ytfzf has become the most powerful tool along these years. Of course I am trying & adding up all your practical tips with ytfzf cli and having big fun. Let alone these tips could also be tested to look up for some foreign episodes of courses or series I guess (some to be tested :slight_smile: ) from scraping.
Awesome that you are recycling a 12y old Netbook to have fun with audio/ video & ytfzf lets your system look like reborn for such streaming tasks.
I wish you could also share some of your personal adventures with fzf in the future in our Forum because we as Mabox users donā€™t know how much potential tools are built-in in our light & solid Manjaro based distribution (Mabox) and I am sure that many forum users could learn more from other usersā€™ experiences. Thanks again.
Cheers.

2 Likes

Thank you! Happy to help. Right now I already implemented fzf in some small skripts and aliases and ideas popping up in my head all the time. Itā€™s like mayonaise - you can slap it on anything :laughing: . If you or napcok arenā€™t faster than me I will start a thread later today in the scripts- and tutorials-section because I didnā€™t found one in the forum. Iā€™d like to see what usecases other people came up with for fzf.

3 Likes

Thank you @napcok.

Please note that yt-download is kind of stagnated since 2021 and yt-dlp is slowy taking his place with more features and steady releases. :wink:

1 Like

ytfzf already switched to yt-dlp.
First post is old :slight_smile:

hello, good evening, how can I change the player instead of mpv so that I can open it with vlc

Consult project documentation on Github GitHub - pystardust/ytfzf: A posix script to find and watch youtube videos from the terminal. (Without API)

1 Like

Mister Everardo,
1.- Open your emulator Terminal.
2.- Type: ytfzf -u vlc & press Enter keyā€¦
3.- Next a new Search line will come up and you type any of your favorite music bands: Backstreet Boysā€¦ then a Backstreet boys songs playlist come up. Pick a song & press Enter.
4.- VLC player (if installed will open & try to reproduce your music videoā€¦) will open to play your Backstreet Boys song
5.- If you want to get back to Mabox default player (MPV) try the same previous step number 2 and replace vlc for mpv in that CLI.

1 Like

as simple as that thank you very much appreciated

1 Like

Any idea about what I should add to my mpv/ytfzf configs to make subtitles appear, because for some reason, I canā€™t get subtitles to appear auto-generated or not, even when I tap J, mpv says no subtitles and I canā€™t figure out why, also, if there is any separate dependency that I need subtitles to work, please tell me about that too