Skip to content

Commit

Permalink
extras: Update extras/mpvc-fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
gmt4 committed Nov 22, 2024
1 parent e594b89 commit c9dd5cf
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions extras/mpvc-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mpvcfzf_icache_output_dir() {
else
MPVC_YTDL_OUTPUT=$(mpvcfzf_icache_output)
MPVC_YTDL_OUTPUT=${MPVC_YTDL_OUTPUT%/*}
eval echo $MPVC_YTDL_OUTPUT
echo "$MPVC_YTDL_OUTPUT" | sed "s|^~|$HOME|"
fi
}

Expand Down Expand Up @@ -225,30 +225,6 @@ mpvcfzf_fetch()
"$ytdlp" $ytdl_opts ${YTDL_OPTS:-} "$@"
}

mpvcfzf_fetch_remove()
{
if [ -z "$1" ]; then
mpvcfzf_warn "$PROGNAME: Error missing ytdl-video-id to remove"
return
fi
ytdl_id="$1"

ytdl_json=$(mpvc getr ytdl-raw-options)
ytdl_archive=$(echo $ytdl_json | jq -r '.data."download-archive"')
ytdl_output=$(echo $ytdl_json | jq -r ".data.output")
ytdl_archive=$(eval echo $ytdl_archive)
ytdl_dir=$(dirname $ytdl_output)
ytdl_dir=$(eval echo $ytdl_dir)

if [ -z "$ytdl_json" -o ! -r "$ytdl_archive" -o ! -n "$ytdl_output" ]; then
mpvcfzf_warn "$PROGNAME: Error cache not enabled: undefined ytdl-raw-options"
return
fi

rm -i "$(find "$ytdl_dir" | grep "$ytdl_id")"
sed -i "/$ytdl_id/ s|^|#|" "$ytdl_archive"
}

mpvcfzf_preview()
{
MPVC_FZF_BIND_HELP="C-u:go C-x:ls C-v:yt C-\\:fs C-s:chapter C-t:add C-o:play C-r:reload C-spc:toggle"
Expand Down Expand Up @@ -395,6 +371,11 @@ mpvcfzf_ddg()
}'
}

mpvcfzf_lofi()
{
mpvcfzf_urlbrowser "${1:-https://lofigirl.com/wp-content/uploads/2023/06/}"
}

mpvcfzf_somafm()
{
chan=${1:-}
Expand Down Expand Up @@ -521,19 +502,18 @@ main()

-o|osearch) shift; mpvcfzf_isearch_once "$arg1" ;; # lucky
-O|Osearch) shift; mpvcfzf_isearch_once "$arg1" | mpvcfzf_awk1 | mpvc load ;; # lucky
-#O) mpvcfzf_icache_output_dir ;;
-OO) shift; mpvcfzf_icache_output_dir ;;

-p|splay) shift; mpvcfzf_iplay "$arg1" | mpvc load; return ;;
-P|Splay) shift; mpvcfzf_iplay "$arg1" | mpvc loadc; return ;;
-r|remove) shift; mpvcfzf_fetch_remove "$arg1"; return ;;
-s|search) shift; mpvcfzf_isearch "$arg1"; return;;
-x|launch) shift; mpvcfzf_launch_term "$@"; exit ;;
-y|related) shift; mpvcfzf_related_search "$arg1"; return ;;
-Y|Related) shift; mpvcfzf_related_play "$arg1"; return ;;
-v|version) shift; mpvcfzf_version; return ;;

now) shift; mpvcfzf_now; return ;;
lofi) shift; mpvcfzf_urlbrowser "${1:-https://lofigirl.com/wp-content/uploads/2023/06/}" ;;
lofi) shift; mpvcfzf_lofi "${1:-}"; return ;;
somafm) shift; mpvcfzf_somafm "${1:-}"; return ;;
radioapi) shift; mpvcfzf_radioapi "${1:-}"; return ;;
#*) shift; mpvcfzf_usage; return ;;
Expand Down

0 comments on commit c9dd5cf

Please sign in to comment.