diff options
Diffstat (limited to '.local/bin/web/fpl')
-rwxr-xr-x | .local/bin/web/fpl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/.local/bin/web/fpl b/.local/bin/web/fpl new file mode 100755 index 0000000..0398770 --- /dev/null +++ b/.local/bin/web/fpl @@ -0,0 +1,39 @@ +#!/bin/sh + +# You can pass any text file containing a list of video titles. +# An fzf prompt will shown to select a video title. +# The script will then try to find a video file whose name fuzzy matches the +# selected title. + +[ -z "$1" ] && { echo "fzf-playlist: browse a list of video titles +USAGE: fpl <PLAYLIST_FILE>" >&2; exit 1; } + +if [ "$OPENFLAG" = 1 ]; then + + if [ -z "$OPENWITH" ]; then + files="$(find "${PWD%/*}")" + else + files="$(find "${PWD%/*}" -name '*.webm' -or -name '*.mkv' -or -name '*.mp4' -or \ + -name '*.mp3' -or -name '*.ogg')" + fi + + if [ -z "$OPENWITH" ]; then + for title in "$@"; do echo "$files" | + fzf --filter "$(printf '%s\n' "$title" | sed 's/[^A-Za-z0-9]*//g')" + echo; done + else + for title in "$@"; do $OPENWITH "$(echo "$files" | + fzf --filter "$(printf '%s\n' "$title" | sed 's/[^A-Za-z0-9]*//g')" | + head -1)"; echo; done + fi + + exit +fi + +file="$(readlink -f "$1")" +cd "${file%/*}" || exit +fzf --multi --reverse \ + --header="Playlist: ${file##*/}" --header-first \ + --bind 'enter:become(OPENFLAG=1 fpl {+})' \ + --bind 'ctrl-o:execute(OPENFLAG=1 OPENWITH=mpv fpl {})' < "$file" + |