Giter VIP home page Giter VIP logo

Comments (21)

pystardust avatar pystardust commented on August 20, 2024 1

I think we will need to modify the scrape algorithm to get more than 40 results. ( we might need to simulate scrolling down on youtube search). I am not entirely sure how to do it. For previews Euro has implemented it. Check out the sample conf.sh.

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024 1

Thats really strange. The image should have taked width = 102 columns, which is half your terminal size.
tty_cols is the number of columns in your terminal and fzf_width is the width ueberzug will display the image with

from ytfzf.

paniash avatar paniash commented on August 20, 2024

@pystardust The partial fix works fine but I have a minor issue. I've written a very rudimentary dmenu wrapper around ytfzf so that I don't have to open my terminal manually. Setting preview_side="right" in conf.sh works expected, provided I manually open my terminal and run ytfzf -t.

My custom wrapper however, doesn't work when used with preview_side="right". The thumbnails get awkwardly centered instead of being placed to the right. This problem does not arise though if I set preview_side="left". Not sure what's going on.

This is my script:

arg=$(echo $1 | dmenu -i -p 'Search YouTube: ')
alacritty -e ytfzf -t $arg

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024

@Euro20179
We will have an issue when using ytfzf right preview from a script ( tput won't work).

The current task is to place the images on the right half of the terminal. But since we don't know the size, we have no clue where to place them.
With left this is not an issue cause we always place them at x=2;y=10.

from ytfzf.

Euro20179 avatar Euro20179 commented on August 20, 2024

I may be misunderstanding the problem, but it seems to work fine at least for me.

I ran ytfzf --previews=right from a script and it worked

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024

@paniash Did you update ytfzf, we had this issue after the first commit. I think it seems to have be fixed now. I just ran it in the same way you mention with st -e ./script and it seems to be working.

from ytfzf.

paniash avatar paniash commented on August 20, 2024

@pystardust I just updated and still have the same issue.

UPDATE: Ok, weird thing. My script works fine on all terminal emulators except alacritty. Also, it seems to work only sometimes on alacritty. About 90% of the time, it doesn't work.

from ytfzf.

paniash avatar paniash commented on August 20, 2024

This is how it appears sometimes on alacritty:
pic-full-210307-0059-02

from ytfzf.

paniash avatar paniash commented on August 20, 2024

Ok, tried it with the development branch as well. The issue still persists.

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024
#!/bin/sh

[ -z "$TTY_COLS" ] && export TTY_COLS="$(tput cols)"
FIFO="/tmp/ytfzf-test-pipe"



start_ub () {
	[ -e "$FIFO" ] || mkfifo "$FIFO"
	# To keep fifo open
	ueberzug layer --parser json < "$FIFO" & 
	exec 3>"$FIFO"
}
stop_ub () {
	# close the redirection
	exec 3>&-
	rm "$FIFO" 
}


preview_img () {
	WIDTH=$FZF_PREVIEW_COLUMNS
	HEIGHT=$FZF_PREVIEW_LINES

	thumb_width=$WIDTH
	thumb_height=$((HEIGHT - 2))

	thumb_x=$(($TTY_COLS / 2 + 3))
	thumb_y=10
	read ueberzug_info << EOF
{ "action": "add", "identifier": "test", "path": "$1", "x": $thumb_x, "y": $thumb_y, "scaler": "fit_contain", "width": $thumb_width, "height": $thumb_height }
EOF
	printf "%s\n" "$ueberzug_info" > "$FIFO"
}

remove_img () {
	read ueberzug_info << EOF
{ "action": "remove", "identifier": "test" }
EOF
	printf "%s\n" "$ueberzug_info" > "$FIFO"
}

if [ "$#" -ge 1 ]; then
	regex='.*\.(png|jpg|gif)$'
	echo "$1" | grep -E -q "$regex" && { preview_img "$1" ; exit; }
	remove_img
	[ -d "$1" ] && { ls "$1" ; exit ; } || { cat "$1" ;}
	exit;
fi


start_ub
ls -1 | fzf --preview-window "right:50%:wrap" \
	--preview "sh $0 {}"
stop_ub

Try this script out. I have rewritten only the parts thare necessary for right image preview.
The script doesn't take arguments. Run it in a directory that contains images, and browse through the images.

from ytfzf.

paniash avatar paniash commented on August 20, 2024

@pystardust Thanks for the script. I've tried it out but the images are weirdly placed towards the right. Attaching a screenshot for reference.

pic-full-210310-1950-49

Also, looks like #118 will take care of the second part of this issue thread.

from ytfzf.

Joseph65 avatar Joseph65 commented on August 20, 2024

i think you can look up for more than 30 results with the current youtube-dl with
youtube-dl ytsearch50:google

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024

Is your left preview working as expected?
I tried the same dmenu wrapper you had mentioned with st, right previews are working well. I also tried alacritty

preview_side=right alacritty -e ytfzf -t stallman

This also worked as expected. Maybe fzf is not giving the right width to the image.
I have modified the previous script a little to display the preview width of fzf and your tty width. Run the script just like the previous one. And share what info is being show on top of the image

#!/bin/sh

[ -z "$TTY_COLS" ] && export TTY_COLS="$(tput cols)"
FIFO="/tmp/ytfzf-test-pipe"



start_ub () {
	[ -e "$FIFO" ] || mkfifo "$FIFO"
	# To keep fifo open
	ueberzug layer --parser json < "$FIFO" & 
	exec 3>"$FIFO"
}
stop_ub () {
	# close the redirection
	exec 3>&-
	rm "$FIFO" 
}


preview_img () {
	WIDTH=$FZF_PREVIEW_COLUMNS
	HEIGHT=$FZF_PREVIEW_LINES

	printf "%s : %s\n" "tty_cols" "$TTY_COLS"
	printf "%s : %s\n" "fzf_width" "$WIDTH"

	thumb_width=$WIDTH
	thumb_height=$((HEIGHT - 2))

	thumb_x=$(($TTY_COLS / 2 + 3))
	thumb_y=10
	read ueberzug_info << EOF
{ "action": "add", "identifier": "test", "path": "$1", "x": $thumb_x, "y": $thumb_y, "scaler": "fit_contain", "width": $thumb_width, "height": $thumb_height }
EOF
	printf "%s\n" "$ueberzug_info" > "$FIFO"
}

remove_img () {
	read ueberzug_info << EOF
{ "action": "remove", "identifier": "test" }
EOF
	printf "%s\n" "$ueberzug_info" > "$FIFO"
}

if [ "$#" -ge 1 ]; then
	regex='.*\.(png|jpg|gif)$'
	echo "$1" | grep -E -q "$regex" && { preview_img "$1" ; exit; }
	remove_img
	[ -d "$1" ] && { ls "$1" ; exit ; } || { cat "$1" ;}
	exit;
fi


start_ub
ls -1 | fzf --preview-window "right:50%:wrap" \
	--preview "sh $0 {}"
stop_ub

from ytfzf.

paniash avatar paniash commented on August 20, 2024

@pystardust I would say that it's slightly better now, but not as good as when rendered with left preview.

pic-full-210315-2000-28

from ytfzf.

pystardust avatar pystardust commented on August 20, 2024

You could always fix this by adjusting the width manually

	local thumb_width=$WIDTH

line 388 in the dev branch

Try changing thumb_width to 150 over here
@paniash
I am not able to think of a general solution that would be compatible with everyone since I am not able to reproduce this issue. But increasing this value will definitly fix the issue for you .

from ytfzf.

Euro20179 avatar Euro20179 commented on August 20, 2024

you could update to 2.2 and try FZF_DEFAULT_OPTS=100% ytfzf ...

from ytfzf.

 avatar commented on August 20, 2024

I have this in the config: --pages=50, but I continue to see only 20 search results. What should I put in the config file?
Version: 2.4.0-1

from ytfzf.

Euro20179 avatar Euro20179 commented on August 20, 2024

pages_to_scrape=50

from ytfzf.

 avatar commented on August 20, 2024

@Euro20179 After pages_to_scrape=50 I have far more than 50 results. After searching three different things I obtain 477, 535 and 528 results. Any way to limit this? Moreover, it is a bit slow.

from ytfzf.

Euro20179 avatar Euro20179 commented on August 20, 2024

Scrape less pages to limit it,
scraping a lot of things is slow; making requests is slow.

from ytfzf.

 avatar commented on August 20, 2024

@Euro20179 Thanks! I have set it to pages_to_scrape=3. Now it gives 60 results.

from ytfzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.