Comments (21)
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.
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.
@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.
@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.
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.
@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.
@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.
This is how it appears sometimes on alacritty:
from ytfzf.
Ok, tried it with the development branch as well. The issue still persists.
from ytfzf.
#!/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.
@pystardust Thanks for the script. I've tried it out but the images are weirdly placed towards the right. Attaching a screenshot for reference.
Also, looks like #118 will take care of the second part of this issue thread.
from ytfzf.
i think you can look up for more than 30 results with the current youtube-dl with
youtube-dl ytsearch50:google
from ytfzf.
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.
@pystardust I would say that it's slightly better now, but not as good as when rendered with left preview.
from ytfzf.
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.
you could update to 2.2 and try FZF_DEFAULT_OPTS=100% ytfzf ...
from ytfzf.
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.
pages_to_scrape=50
from ytfzf.
@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.
Scrape less pages to limit it,
scraping a lot of things is slow; making requests is slow.
from ytfzf.
@Euro20179 Thanks! I have set it to pages_to_scrape=3
. Now it gives 60 results.
from ytfzf.
Related Issues (20)
- strange bug overwriting and repeat text on top of first text HOT 8
- [Feature request]: interactively change the sort order HOT 2
- [BUG]: Misaligned description items on start with --preview-side=bottom HOT 2
- [Feature request]: Enable external thumbnails without info pane in fzf or preserve thumbnail viewer window HOT 2
- [BUG]: Broken character encoding when using the yt-music scraper HOT 11
- [BUG]: socat, and mpv must be installed for the mpv thumbnail viewer
- [BUG]: mpv installed with flatpak is not recognized HOT 4
- [BUG]: thumbnails won't load when requesting more pages HOT 2
- [BUG]: shift `-1` is not a valid option HOT 1
- [BUG]: using nonalphanumeric characters in optstring produces unspecified results HOT 2
- [Feature request]: shuffle playlist HOT 4
- How do I change the default quality of the videos? HOT 2
- [Feature request]: YouTube Podcast
- how to show the video thumbnail imae on the terminal HOT 1
- how to play only audio using elisa music player
- Subscriptions are not working on OpenBSD HOT 1
- [BUG]: ERROR: Nothing was scraped no matter which instance I use HOT 4
- [BUG]: Unable to extract uploader id; HOT 2
- [BUG]: vo/gpu error
- [BUG]: ytfzf It tells me that there is no quality format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ytfzf.