Skip to content
forked from pystardust/ytfzf

A posix script to find and watch youtube videos from the terminal. (Without API)

License

Notifications You must be signed in to change notification settings

krivahtoo/ytfzf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation



Discord

A POSIX script that helps you find Youtube videos (without API) and opens/downloads them using mpv/youtube-dl


This is a little showcase

Table of Contents

These links will take you where you want to go with the snap of a finger

Features

  • Thumbnails
  • History
  • Download
  • Format selection
  • Queue multiple videos

Usage-Instructions

ytfzf [Options] <search-query>

Videos can be selected using fzf, dmenu or rofi.

To quit the script you can press ESC or ^C in the video selection prompt.

  • Config file:

~/.config/ytfzf/conf.sh, example config file.

Any variable change mentioned below can be exported, or added to the config file.

  • Thumbnails:

requires ueberzug (works only on X11), doesn't work on wayland and macos

```sh
ytfzf -t <search-query>
```

Thumbnails preview side could be changed to the right with --preview-side=right

  • History:

     ytfzf -H
    • clear history
     ytfzf -x
    • History file: ~/.cache/ytfzf/ytfzf_hst

History is enabled by default. To turn it off you can export YTFZF_HIST=0 or set add it to the config file.

  • External menu

    • -D: To use external menu

By default the external menu is set to dmenu -i -l 30. This can be changed to rofi

```sh
YTFZF_EXTMENU=' rofi -dmenu -fuzzy -width 1500'
```

The width of external menu can be adjusted with YTFZF_EXTMENU_LEN=220.

  • Format-selction and download

     YTFZF_PREF="22"                   # 22 for 720p
    • -f: To view and select available formats.

    • -m: (audio-only) Only audio format (best audio)

    • -d: (download) To download a video instead of playing it.

  • Multi-selection:

multiple videos can be queued up using fzf's auto multi-selection (tab). To traverse between selected videos use < and >.

  • Looping, Searches

    • -l: (loop) would prompt the video menu every time a video finishes. Press ESC or ^C to exit loop.
    • -s: (search-again) would ask for another search query as the video ends.
  • Auto and random selection

To select videos without video prompt, if multiple videos are selected then they would play one after the other. The variable n represents the link count. Which is 1 by default.

+ `-A`: (select-all) selects all the videos.
+ `-a`: (auto-selection) selects the first **n**(=1) result.
+ `-r`: (auto-selection) Randomly selects **n**(=1) results (shuffles them).

+ `-n <number>` : (link-count) Set **n** the number of links to be selected.
  • Subscriptions

Subscriptions are managed in subscription file: ~/.config/ytfzf/subscriptions.

+ Adding a certain channel to subscriptions

1. Open the channel page on a browser and go to the vidoes tab (located right below the channel name and subscription count).
2. Copy the url of videos page. And add it to your subscription file.
3. The url for each subscription must be on a separate line.

The subscription file needs to have only the channels' video page url. Comments can be added with #

```
# file : ~/.config/ytfzf/subscriptions
## tech channels
https://www.youtube.com/c/LukeSmithxyz/videos                   # luke smith
https://www.youtube.com/channel/UCngn7SVujlvskHRvRKc1cTw/videos # bugswriter
https://www.youtube.com/c/DistroTube/videos                     # distrotube
https://www.youtube.com/c/MentalOutlaw/videos                   # mental outlaw
```

To see subscriptions' latest videos

```sh
# Defaults to 10 results from each channel
ytfzf -S

# To show 15 results instead
ytfzf --subs=15
```

This can be combined with other options like thumbnails

```sh
ytfzf -tS
```
  • Custom Player

By default, ytfzf uses mpv. Custom player should have the ability to launch youtube links (example: vlc).

```sh
# example: using devour
FZF_PLAYER="devour mpv"
YTFZF_PLAYER_FORMAT="devour mpv --ytdl-format="
```
  • Misc

    • The currently playing video details are stored in ~/.cache/ytfzf_cur (for status bar modules)

    • Files and directories used by ytfzf can be set in the config file

     cache_dir="$HOME/.cache/ytfzf"
     history_file="$YTFZF_CACHE/ytfzf_hst"
     current_file="$YTFZF_CACHE/ytfzf_cur"
     thumb_dir="$YTFZF_CACHE/thumb"

Useful mpv key bindings

  • f : full screen
  • j,J: cycle subtitles (also works with audio, if the music video has subtitles)
  • L : single-loop

Examples

  • Search with Thumbnails

    Find and watch videos with thumbnail previews

    ytfzf -t <query>
    

    Show all subscriptions with thumbnails (latest 10)

    ytfzf -St
    
  • You can use multiple options together, here are some examples

    • Stream audio (music), and prompt as the music finishes

      ytfzf -ml <query>
      
    • Download a video from your history

      ytfzf -dH
      
    • Open using external menu 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
    

Update log

  • Subscriptions
  • Now ytfzf can queue videos using fzf multiselect option. Press tab to select a video. All the videos will be lined up in mpv. Use > and < to traverse them.
  • Make continuous queries with -s
  • Thumbnails! Using Ueberzug. Inspired by fontpreview-ueberzug.
  • added MacOS support
  • Stdin can be taken by using ytfzf -, for both fzf and external menu.

Dependencies

Fzf is optional, you can use an external menu (like dmenu) with the -D option (no thumbnail support).

Thumbnails only work with fzf and Ueberzug as of now.

  • Arch based

    sudo pacman -S jq mpv youtube-dl fzf
    

    For thumbnails

    sudo pacman -S ueberzug
    
  • Debian based

    sudo apt install jq mpv youtube-dl fzf
    

    For thumbnails

    pip install ueberzug
    

    Note youtube-dl is usually outdated in debian repos, I suggest getting it from youtube-dl github

  • MacOS

    brew install jq mpv youtube-dl fzf
    

    At the moment thumbnail previews aren't working on MacOS

Installation

  • Installation by direct download

     sudo curl -L "https://raw.githubusercontent.com/pystardust/ytfzf/master/ytfzf" -o /usr/bin/ytfzf
     sudo chmod +x /usr/bin/ytfzf
  • Installation by cloning the repository

     git clone https://github.com/pystardust/ytfzf
     cd ytfzf
    • Install with the Makefile
       sudo make install
    • Uninstall with the Makefile
       sudo make uninstall
  • Arch users can install ytfzf from the AUR

      yay -S ytfzf-git
    
  • Gentoo users can install ytfzf from the nitratesky overlay

      eselect repository enable nitratesky
      emerge -a1 net-misc/ytfzf
    

Todo πŸ“

  • Playlists
  • More sites
  • Subscriptions
  • Thumbnails

Bugs ❌

  • dwm with swallow patch: Images don't render when looped (ie, option -l)
  • If thubnails are not working .Xautority might be causing it. Try deleting .Xauthority and relogging.

About

A posix script to find and watch youtube videos from the terminal. (Without API)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 99.3%
  • Makefile 0.7%