pystardust / ytfzf

A posix script to find and watch youtube videos from the terminal. (Without API)
GNU General Public License v3.0
3.73k stars 346 forks source link

[BUG]: ytfzf: Thumbnails not getting displayed #524

Open lamyergeier opened 2 years ago

lamyergeier commented 2 years ago

To Reproduce

$ ytfzf --show-thumbnails  Ted
/home/anish/opt/bin/ytfzf: 1821: scrape_yt_search: not found
invalid scraper: yt_search

Information

$ ls -l "$(which sh)"
lrwxrwxrwx 1 root 4 Jan  4 15:37 /usr/bin/sh -> dash*
Euro20179 commented 2 years ago

Do you have a config, if so whats in it?

ytfzf --show-thumbnails -cY ... should work

lamyergeier commented 2 years ago
$ type ytfzf 
ytfzf is /usr/local/bin/ytfzf

on X11 display Linuxmint 20.3 (Refer: How to know whether Wayland or X11 is being used - Unix & Linux Stack Exchange)

$ echo $XDG_SESSION_TYPE
x11

$ loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type
Type=x11

I have installed all dependencies:

$ type jq
jq is /home/linuxbrew/.linuxbrew/bin/jq

$ type curl
curl is /usr/bin/curl
curl is /bin/curl
curl is /home/linuxbrew/.linuxbrew/bin/curl

$ type mpv
mpv is /home/linuxbrew/.linuxbrew/bin/mpv

$ type fzf
fzf is /home/linuxbrew/.linuxbrew/bin/fzf
fzf is /home/linuxbrew/.linuxbrew/opt/fzf/bin/fzf

$ type yt-dlp 
yt-dlp is /home/linuxbrew/.linuxbrew/bin/yt-dlp

$ type ueberzug
ueberzug is /home/nikhil/.local/bin/ueberzug

ytfzf -t works but shows no thumbnails:

image

Config file

video_player="vlc"
audio_player="vlc"
Euro20179 commented 2 years ago

ueberzug inst installed on the same place as everything else, you should try sudo pip3 install ueberzug

Euro20179 commented 2 years ago

just realized your config peobably doesnt do what you want, you probably want something more like this


audio_player () {
    vlc "$@"

}

video_player (){
    vlc "$@"
}
lamyergeier commented 2 years ago

ueberzug inst installed on the same place as everything else, you should try sudo pip3 install ueberzug

Instead of running the shell script installed in /usr/local/bin, I ran the shell script at the cloned repository as follows:

image


It turns that ueberzug is broken, any suggestion how to fix it?

$ /home/nikhil/.local/bin/pip3 install ueberzug
Defaulting to user installation because normal site-packages is not writeable
Collecting ueberzug
  Using cached ueberzug-18.1.9.tar.gz (36 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: attrs>=18.2.0 in /home/nikhil/.local/lib/python3.8/site-packages (from ueberzug) (21.4.0)
Requirement already satisfied: docopt in /usr/lib/python3/dist-packages (from ueberzug) (0.6.2)
Requirement already satisfied: pillow in /home/nikhil/.local/lib/python3.8/site-packages (from ueberzug) (9.0.1)
Requirement already satisfied: python-xlib in /home/nikhil/.local/lib/python3.8/site-packages (from ueberzug) (0.31)
Requirement already satisfied: six>=1.10.0 in /home/nikhil/.local/lib/python3.8/site-packages (from python-xlib->ueberzug) (1.16.0)
Building wheels for collected packages: ueberzug
  Building wheel for ueberzug (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/action.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/files.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/thread.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/__main__.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/loading.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/library.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/xutil.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/batch.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/ui.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/geometry.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/tmux_util.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/scaling.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/query_windows.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/terminal.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/pattern.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/parser.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/conversion.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/process.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/version.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/layer.py -> build/lib.linux-x86_64-3.8/ueberzug
      creating build/lib.linux-x86_64-3.8/ueberzug/lib
      copying ueberzug/lib/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug/lib
      creating build/lib.linux-x86_64-3.8/ueberzug/lib/v0
      copying ueberzug/lib/v0/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug/lib/v0
      running egg_info
      writing ueberzug.egg-info/PKG-INFO
      writing dependency_links to ueberzug.egg-info/dependency_links.txt
      writing entry points to ueberzug.egg-info/entry_points.txt
      writing requirements to ueberzug.egg-info/requires.txt
      writing top-level names to ueberzug.egg-info/top_level.txt
      listing git files failed - pretending there aren't any
      listing git files failed - pretending there aren't any
      reading manifest file 'ueberzug.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'ueberzug.egg-info/SOURCES.txt'
      copying ueberzug/lib/lib.sh -> build/lib.linux-x86_64-3.8/ueberzug/lib
      running build_ext
      building 'Xshm' extension
      creating build/temp.linux-x86_64-3.8
      creating build/temp.linux-x86_64-3.8/Xshm
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c Xshm/Xshm.c -o build/temp.linux-x86_64-3.8/Xshm/Xshm.o
      Xshm/Xshm.c:2:10: fatal error: Python.h: No such file or directory
          2 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ueberzug
  Running setup.py clean for ueberzug
Failed to build ueberzug
Installing collected packages: ueberzug
  Running setup.py install for ueberzug ... error
  error: subprocess-exited-with-error

  × Running setup.py install for ueberzug did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/action.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/files.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/thread.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/__main__.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/loading.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/library.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/xutil.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/batch.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/ui.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/geometry.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/tmux_util.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/scaling.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/query_windows.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/terminal.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/pattern.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/parser.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/conversion.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/process.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/version.py -> build/lib.linux-x86_64-3.8/ueberzug
      copying ueberzug/layer.py -> build/lib.linux-x86_64-3.8/ueberzug
      creating build/lib.linux-x86_64-3.8/ueberzug/lib
      copying ueberzug/lib/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug/lib
      creating build/lib.linux-x86_64-3.8/ueberzug/lib/v0
      copying ueberzug/lib/v0/__init__.py -> build/lib.linux-x86_64-3.8/ueberzug/lib/v0
      running egg_info
      writing ueberzug.egg-info/PKG-INFO
      writing dependency_links to ueberzug.egg-info/dependency_links.txt
      writing entry points to ueberzug.egg-info/entry_points.txt
      writing requirements to ueberzug.egg-info/requires.txt
      writing top-level names to ueberzug.egg-info/top_level.txt
      listing git files failed - pretending there aren't any
      listing git files failed - pretending there aren't any
      reading manifest file 'ueberzug.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'ueberzug.egg-info/SOURCES.txt'
      copying ueberzug/lib/lib.sh -> build/lib.linux-x86_64-3.8/ueberzug/lib
      running build_ext
      building 'Xshm' extension
      creating build/temp.linux-x86_64-3.8
      creating build/temp.linux-x86_64-3.8/Xshm
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c Xshm/Xshm.c -o build/temp.linux-x86_64-3.8/Xshm/Xshm.o
      Xshm/Xshm.c:2:10: fatal error: Python.h: No such file or directory
          2 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> ueberzug
Euro20179 commented 2 years ago

It seems your missing the python.h header file.

Try sudo apt install python3-devel python-devel and try installing ueberzug again.

lamyergeier commented 2 years ago

I successfully installed ueberzug as you suggested, but I still don't get any thumbnail. May be ytfzf could print some helpful debug message to identify what is going wrong? OR what do you suggest?

image

image


Also, now videos stopped playing as shown below

image

Euro20179 commented 2 years ago

Try using the development version, that should give an error if ueberzug isn't installed or something

git clone -b development https://github.com/pystardust/ytfzf
cd ytfzf
./ytfzf -t ...

If ueberzug still doesn't work try running this script in a place with .png files

#!/bin/sh

files="$(printf "%s\n" *.png)"

fifo="ueberzug-fifo"
mkfifo "$fifo"
ueberzug layer --parser json < "$fifo" &
exec 3> "$fifo"

while read -r file; do
    {
        printf "{"
        printf '"%s": "%s",' \
            'action' 'add' \
            'identifier' 'f' \
            'path' "$file" \
            'x' "0" \
            'y' "0" \
            'scaler' 'fit_contain' \
            'width' "20"
        printf '"%s": "%s"' 'height' "20"
        printf "}\n"
    } > "$fifo"
    sleep 1
done <<EOF
$files
EOF

The images should appear in the top left corner of the terminal

About the loading of videos, I'm not sure why it's doing that.

mizzunet commented 2 years ago

Same here image config


#ytdl_pref="139+133"
cache_dir="/tmp"

video_pref="133"
audio_pref="139"

fzf_preview_side=right
thumbnail_viewer=chafa 
show_thumbnails=1
thumbnail_quality=start
is_loop=1

ytdl_path=/usr/bin/yt-dlp
Euro20179 commented 2 years ago

What's the output of ls -l $(which sh), and whats youre ytfzf version?

mizzunet commented 2 years ago

@Euro20179 󰅂 ls -l $(which sh) lrwxrwxrwx 4 root 9 Jan 02:36  /usr/bin/sh -> bash

version: 2.2.1.rc-6

mizzunet commented 2 years ago

I noticed that, ytzf tries to render thumbnail(chafa)

image

Edit: terminal is foot on SwayWm

Edit 2:

I just tried on alacritty, thumbail displays. So I guess it's foot's own issue.

image

dnkl commented 2 years ago

I just tried on alacritty, thumbail displays. So I guess it's foot's own issue.

Not really. Chafa enables sixel by default on foot, which ytfzf doesn't support(?). Alacritty doesn't support sixel, and there chafa uses plain ASCII "graphics", which does work.

If you can configure the chafa command line, add --format=symbols to force ASCII graphics.

mizzunet commented 2 years ago

Hmm, it seems chafa works very well on foot image

If you can configure the chafa command line, add --format=symbols to force ASCII graphics.

I'm not sure if I can pass arguments for $thumbnail_viewer

Would you test ytfzf on your end with chafa as thumbail viewer?

Euro20179 commented 2 years ago

which ytfzf doesn't support(?).

fzf doeant support sixel, therefore ytzf doesnt support it

If you can configure the chafa command line, add --format=symbols to force ASCII graphics.

Ill do this in ytfzf I was unaware chafa tries to use sixel sometimes

GhoulBoii commented 2 years ago

Hi! Sorry for commenting on a 5 month old issue but this is a unfixable issue of ueberzug with certain terminals, one of them being gnome-terminal.

chris-aeviator commented 1 year ago

Try using the development version, that should give an error if ueberzug isn't installed or something

git clone -b development https://github.com/pystardust/ytfzf
cd ytfzf
./ytfzf -t ...

If ueberzug still doesn't work try running this script in a place with .png files

#!/bin/sh

files="$(printf "%s\n" *.png)"

fifo="ueberzug-fifo"
mkfifo "$fifo"
ueberzug layer --parser json < "$fifo" &
exec 3> "$fifo"

while read -r file; do
    {
        printf "{"
        printf '"%s": "%s",' \
            'action' 'add' \
            'identifier' 'f' \
            'path' "$file" \
            'x' "0" \
            'y' "0" \
            'scaler' 'fit_contain' \
            'width' "20"
        printf '"%s": "%s"' 'height' "20"
        printf "}\n"
    } > "$fifo"
    sleep 1
done <<EOF
$files
EOF

The images should appear in the top left corner of the terminal

About the loading of videos, I'm not sure why it's doing that.

when running this script I can see

{"type": "error", "name": "AttributeError", "message": "module 'PIL.Image' has no attribute 'ANTIALIAS'"}

. PIL ANTIALIAS has been deprecated and might be a source of issues (with ueberzug though)

Update

Installing this package from ueber-devel/ueberzug readme fixes the issue for me and thumbnails display

Note: You can improve the performance of image manipulation functions by using pillow-simd instead of pillow.