diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2025-06-09 19:07:42 -0500 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2025-06-09 19:07:42 -0500 |
| commit | 796b4c064ffb13813a6f19d982b6605de900ab57 (patch) | |
| tree | b3a6c5c674c7c4f28334808efc0191fade8212d8 /getyt | |
| parent | 475c01dc1928ef92b755b6e3b8d749fc936ad91a (diff) | |
removed last changed. it was allready doing the thing i wanted. renamed get_yt2.sh to getyt. added actual args
Diffstat (limited to 'getyt')
| -rwxr-xr-x | getyt | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -0,0 +1,47 @@ +#!/bin/bash +FZF_PREVIEW_LINES=20 +FZF_PREVIEW_COLUMN=3 + + +cd "$(dirname "$0")" +has_chafa=0 + +while getopts "c" opt; do + case "$opt" in + c) has_chafa=1 + ;; + esac +done + +shift $((OPTIND-1)) +[ "${1:-}" = "--" ] && shift + +! command -v chafa >/dev/null && has_chafa=0 + +playlist=$1 + + +if [ "$playlist" == "" ]; then + item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist")" +else + item="$(sqlite3 ./youtube_stuffs.db "select rowid,* from ytlist where category='$playlist'")" +fi + + +if [ "$has_chafa" == "1" ]; then + item="$( printf -- "%s" "$item" | \ + fzf --preview "./preview.sh {} | xargs chafa --clear -f iterm -s ${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" \ + | sed -- 's/|.*//g')" +else + item="$( printf -- "%s" "$item" | \ + fzf \ + | sed -- 's/|.*//g')" +fi + + +url=$(sqlite3 ./youtube_stuffs.db "select id from ytlist where rowid=$item") +if [ -z "$WAYLAND_DISPLAY" ]; then + printf "https://youtube.com/watch?v=$url" | xclip -selection clipboard +else + printf "https://youtube.com/watch?v=$url" | wl-copy +fi |
