Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Euro20179 committed May 11, 2023
2 parents 078ccf5 + d917814 commit e306122
Show file tree
Hide file tree
Showing 12 changed files with 2,037 additions and 1,963 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assignees: ''
- OS:
- Terminal:
- Ytfzf version:
- Output of `ls -l "$(which sh)"` (if you're using fish: `ls -l (which sh)`):
- Output of `readlink $(which sh)`:
- (if is a thumbnail issue) run `ytfzf --thumbnail-log=log.txt` and post the file:


Expand Down
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,26 @@ There are only 2 required dependencies, however the rest require some configurat

* [`yt-dlp`](https://github.com/yt-dlp/yt-dlp) (for downloading)
* [`dmenu`](https://tools.suckless.org/dmenu/) (only if using the -D option)
* [`ueberzug`](https://github.com/seebye/ueberzug) (if using thumbnails (-t) on x11)
* If on wayland, or you do not want `ueberzug`, see the alternatives [below](#Alternative-Thumbnail-Viewers).
* To use an alternative include `-T <alternative>` in the command when running ytfzf

### Alternative Thumbnail Viewers
| Program | Wayland Support |
| :-- | :-- |
| [`chafa`](https://github.com/hpjansson/chafa) | &#9989; |
| [`catimg`](https://github.com/posva/catimg) | &#9989; |
| [`imv`](https://git.sr.ht/~exec64/imv) | &#9989; |
| [`mpv`](https://github.com/mpv-player/mpv) | &#9989; |
| [`kitty`](https://github.com/kovidgoyal/kitty) | &#9989; |
| [`swayimg`](https://github.com/artemsen/swayimg) | only on `sway` |
| [`swayimg`](https://github.com/artemsen/swayimg) (-T swayimg-hyprland) | only on `hyprland` |
* [`ueberzugpp`](https://github.com/jstkdng/ueberzugpp)
* needed for the following thumbnail viewers:
* `kitty`, `iterm2`, `sixel`, and `ueberzug`
* the original [`ueberzug`](https://github.com/seebye/ueberzug) or any fork may be used if you only want to use the `ueberzug` viewer.

### Thumbnail Viewers

* **To use a thumbnail viewer include `-T <viewer>` in the command when running ytfzf**

| Program | Wayland Support |
| :-- | :-- |
| [`kitty`](https://github.com/kovidgoyal/kitty) (requires `ueberzugpp`) | &#9989; |
| `iterm2` (requires `ueberzugpp`) | &#9989; |
| `sixel` (requires `ueberzugpp`) | &#9989; |
| [`chafa`](https://github.com/hpjansson/chafa) | &#9989; |
| [`catimg`](https://github.com/posva/catimg) | &#9989; |
| [`imv`](https://git.sr.ht/~exec64/imv) | &#9989; |
| [`mpv`](https://github.com/mpv-player/mpv) | &#9989; |
| [`swayimg`](https://github.com/artemsen/swayimg) | only on `sway` |
| [`swayimg`](https://github.com/artemsen/swayimg) (-T swayimg-hyprland) | only on `hyprland` |

# Install

Expand Down Expand Up @@ -191,7 +197,7 @@ Feel free to contribute, and add your name to the credits, please use the develo
| User | Contributions | Donate|
| :--- | :--- | :--- |
| Pystardust | [contributions](credits/pystardust.md) ||
| Euro20179 | [contributions](credits/euro20179.md) | [donate](credits/euro20179.md#Donate) |
| Euro20179 | [contributions](credits/euro20179.md) ||
| Simonhughxyz | [contributions](credits/simonhughxyz.md) ||
| Jac-Zac | [contributions](credits/jac-zac.md) ||
| Mudskipper875 | [contributions](credits/mudskipper875.md) ||
Expand Down
54 changes: 31 additions & 23 deletions addons/extensions/auto-thumb
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#!/bin/sh

case "${XDG_SESSION_TYPE}" in
wayland)
if command_exists "swayimg"; then
case "${XDG_CURRENT_DESKTOP}" in
Hyprland) thumbnail_viewer=swayimg-hyprland ;;
sway) thumbnail_viewer=swayimg ;;
esac
else
thumbnail_viewer=chafa
fi
;;
X11)
if command_exists "ueberzug"; then
thumbnail_viewer=ueberzug
else
thumbnail_viewer=chafa
fi
;;
tty) thumbnail_viewer=chafa ;;
*)
print_warning "XDG_SESSION_TYPE is not set, defaulting to chafa\n"
thumbnail_viewer=chafa ;;
esac

if [ "$XDG_SESSION_TYPE" = "X11" ]; then
command_exists "ueberzug" && thumbnail_viewer=ueberzug
elif command_exists "ueberzugpp"; then
case "$TERM" in
xterm-kitty) thumbnail_viewer=kitty ;;
foot) thumbnail_viewer=sixel ;;
wezterm|iterm2) thumbnail_viewer=iterm2 ;;
esac
else
case "${XDG_SESSION_TYPE}" in
wayland)
if command_exists "swayimg"; then
case "${XDG_CURRENT_DESKTOP}" in
Hyprland) thumbnail_viewer=swayimg-hyprland ;;
sway) thumbnail_viewer=swayimg ;;
esac
else
thumbnail_viewer=chafa
fi
;;
X11|tty)
thumbnail_viewer=chafa ;;
*)
print_warning "XDG_SESSION_TYPE is not set, defaulting to chafa\n"
thumbnail_viewer=chafa ;;
esac
fi


print_info "Thumbnail viewer: $thumbnail_viewer\n"
30 changes: 30 additions & 0 deletions addons/extensions/comments
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

get_search_from_EXT_comments (){
_search="${selected_url}"
}

set +f
instances=$(printf "%s\n" "${YTFZF_TEMP_DIR}"/*)
set -f

instance_count=$(echo "$instances" | wc -l)

if [ "$instance_count" -gt 1 ]; then
printf "%s\n" "More than 1 ytfzf instance is running, please select one"
echo "$instances" | sed 's/.*\///' | nl
read -r num

instance="$(echo "$instances" | sed -n "${num}p")"
else
instance="$instances"
fi

read -r selected_url < "${instance}/ids"

[ -z "$selected_url" ] && {
printf "%s\n" "This instance is not playing a video"
}

scrape="comments"
search_source="EXT_comments"
5 changes: 3 additions & 2 deletions addons/extensions/playlists
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ on_opt_parse_list_titles () {
exit 0
}

on_search_playlists () {
ext_on_search_playlists () {
[ -z "$_playlists_playlist_name" ] && return 0
url_handler_opts="playlist_name=${PLAYLISTS_YTFZF_DIR}/${_playlists_playlist_name}$(printf '\033')ytfzf_data=$ytfzf_video_json_file"
export _PLAYLIST_NAME=${PLAYLISTS_YTFZF_DIR}/${_playlists_playlist_name}
export YTFZF_VIDEO_JSON_FILE="${ytfzf_video_json_file}"
}
38 changes: 23 additions & 15 deletions addons/interfaces/sixel-menu/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ def __init__(self, *data):
self.selectedLine = 0
self.outputCache = {}

def renderPreview(self, line):
sys.stderr.write("\033[s")
sys.stderr.write(f'\033[0;{TERMCOLUMNS // 2 + 1}H')
if self.outputCache.get(self.selectedLine):
sys.stderr.write(self.outputCache[self.selectedLine])
else:
cmd = list(map(lambda x: x.replace(
"{}", line), self.renderCmd))
o = subprocess.check_output(cmd).decode("utf-8")
self.outputCache[self.selectedLine] = o
sys.stderr.write(o + "\n")
sys.stderr.write("\033[u")

def render(self):
start = max(0, self.selectedLine - TERMLINES // 2)
end = min(len(self) + 1, self.selectedLine + TERMLINES // 2)
Expand All @@ -87,19 +100,8 @@ def render(self):
if len(line) > TERMCOLUMNS // 2:
displayLine = line[0:TERMCOLUMNS // 2]
if i == self.selectedLine:
sys.stderr.write("\033[s")
sys.stderr.write(f'\033[0;{TERMCOLUMNS // 2 + 1}H')
if self.renderCmd:
if self.outputCache.get(self.selectedLine):
sys.stderr.write(self.outputCache[self.selectedLine])
else:
cmd = list(map(lambda x: x.replace(
"{}", line), self.renderCmd))

o = subprocess.check_output(cmd).decode("utf-8")
self.outputCache[self.selectedLine] = o
sys.stderr.write(o + "\n")
sys.stderr.write("\033[u")
self.renderPreview(line)
sys.stderr.write('\033[31m')
sys.stderr.write(displayLine + "\033[0m\n\r")
i += 1
Expand All @@ -121,9 +123,15 @@ def up(self):


LINES = Lines()

if not sys.argv[1]:
sys.stderr.write("No file to read\n")
exit(1)

with open(sys.argv[1], "r") as f:
for line in f.read().split("\n"):
if not line: continue
if not line:
continue
try:
LINES.append(line.strip())
except Exception as err:
Expand All @@ -137,13 +145,14 @@ def up(self):
else:
LINES.renderCmd = ["img2sixel", "-w", "100", "{}"]


#TOOD: add :command, such as :copy to copy the current line
while True:
for f in sys.stderr, sys.stdout:
f.write("\033[2J\033[0;0H")

LINES.render()


sys.stderr.write(f'\033[0;{TERMCOLUMNS // 2}H')
k = getInput()

Expand All @@ -166,4 +175,3 @@ def up(self):
for fd in sys.stderr, sys.stdout:
fd.write("\033[2J\033[0;0H")
print(LINES[LINES.selectedLine])

13 changes: 0 additions & 13 deletions addons/thumbnail-viewers/kitty

This file was deleted.

5 changes: 2 additions & 3 deletions addons/url-handlers/atp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

read -r _ytdl_pref _is_audio_only _is_detach _video_pref _audio_pref url_handler_opts _

ytfzf_video_json_file="${url_handler_opts##*ytfzf_data=}"
ytfzf_video_json_file="${YTFZF_VIDEO_JSON_FILE}"

playlist_name="${url_handler_opts%%"$(printf '\033')"*}"
playlist_name="${playlist_name#playlist_name=}"
playlist_name="${_PLAYLIST_NAME}"

for url in "$@"; do
jq -r --arg url "$url" '.[]|select(.url==$url)' < "$ytfzf_video_json_file"
Expand Down
5 changes: 2 additions & 3 deletions addons/url-handlers/rfp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

read -r _ytdl_pref _is_audio_only _is_detach _video_pref _audio_pref url_handler_opts _

ytfzf_video_json_file="${url_handler_opts##*ytfzf_data=}"
ytfzf_video_json_file="${YTFZF_VIDEO_JSON_FILE}"

playlist_name="${url_handler_opts%%"$(printf '\033')"*}"
playlist_name="${playlist_name#playlist_name=}"
playlist_name="${_PLAYLIST_NAME}"

old_data="$(cat "$playlist_name")"

Expand Down
4 changes: 0 additions & 4 deletions credits/euro20179.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
* conf.sh
* addons
* playlists

<img alt="# Donate" src="https://img.shields.io/badge/User-Donate-00aaaa?style=flat-square">

Monero: 44XcVjiCZxyARkV7MeaiSA7fgkf4vaTd6A14Dywric9LYshieufXPMRGntjCbBReCW8PyyWwcu6kV8xdXz5QYBKCFF5n88g
42 changes: 9 additions & 33 deletions docs/man/ytfzf.5
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ It is recommended to not use this variable directly, instead use
Valid options:
.RS
.TP
.IR sixel
.TP
.IR iterm2
.TP
.IR kitty
.TP
.TP
.IR ueberzug
.TP
.IR chafa
.TP
.IR chafa-16
Expand Down Expand Up @@ -1121,14 +1130,6 @@ This function is called if ytfzf is started without a search. (and is using the
.br
This function takes no arguments.
.TP
.BR search_prompt_scripting ()
This function asks the user to make a search query, and sets the variable $_search to the query.
.br
This function is called if ytfzf is started without a search. (and is using the \-r, \-a, or \-A flag)
.br
This function takes no arguments.
.TP
.BR quick_menu ()
This function should take user input and echo it back
Expand All @@ -1153,18 +1154,6 @@ This function takes 1 argument, and takes input from stdin
.br
stdin: the items to choose from (separated by new lines)
.TP
.BR quick_menu_scripting ()
This function should do the same thing as quick_menu()
.br
This function is called when quick_menu() would be called, but when \-a, \-r, or \-A is enabled.
.br
This function takes 1 argument, and takes input from stdin
.br
1: The prompt to use.
.br
stdin: the items to choose from (separated by new lines)
.TP
.BR info_wait_prompt ()
The prompt to use when \fBinfo_wait\fR is enabled.
Expand All @@ -1177,12 +1166,6 @@ Same as \fBinfo_wait_prompt()\fR when \-D is used.
.br
This function takes no arguments.
.TP
.BR info_wait_prompt_scripting ()
Same as \fBinfo_wait_prompt()\fR when \-S, \-a, or \-A is used.
.br
This function takes no arguments.
.TP
.BR info_wait_prompt_wrapper ()
Call info_wait_prompt_<interface_name>
Expand All @@ -1202,13 +1185,6 @@ Print text to standard out.
This function takes an unlimited number of arguments to print.
.RE
.TP
.BR display_text_scripting ()
Print text to standard out.
.br
This function takes an unlimited number of arguments to print.
.RE
.TP
.BR display_text_wrapper ()
Call display_text_<interface_name>
Expand Down
Loading

0 comments on commit e306122

Please sign in to comment.