plumber: add ytdl:// support - randomcrap - random crap programs of varying quality
 (HTM) git clone git://git.codemadness.org/randomcrap
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2f4698f34d63b5174d92dc62df93bc7877d06abc
 (DIR) parent b8b2cc59aa85a43f6d7e9a8ce4b1c7627e4fa264
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat,  3 Feb 2024 11:45:20 +0100
       
       plumber: add ytdl:// support
       
       Diffstat:
         M config/scripts/mpv.sh               |       2 +-
         M config/scripts/plumb.sh             |      12 +++++++-----
       
       2 files changed, 8 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/config/scripts/mpv.sh b/config/scripts/mpv.sh
       @@ -31,7 +31,7 @@ nlines=$(($(printf '%s\n' "$text" | wc -l) + 0))
        if test x"${nlines}" != x"1"; then
                text=$(printf '%s\n' "$text" | ~/.config/scripts/dmenu_urls.sh)
        else
       -        text=$(printf '%s\n' "$text" | sed -nE 's@^.*(http|https|gopher|gophers)://(.*)$@\1://\2@p')
       +        text=$(printf '%s\n' "$text" | sed -nE 's@^.*(http|https|gopher|gophers|ytdl)://(.*)$@\1://\2@p')
        fi
        
        movie "$text"
 (DIR) diff --git a/config/scripts/plumb.sh b/config/scripts/plumb.sh
       @@ -7,7 +7,7 @@ match() {
        
        # isallowedproto(url)
        isallowedproto() {
       -        match "$1" '^(http|https|gopher|gophers|rtmp|lbry)://'
       +        match "$1" '^(http|https|gopher|gophers|rtmp|lbry|ytdl)://'
        }
        
        # isgraphical mode? X11 or not.
       @@ -91,10 +91,10 @@ if [ x"$2" != x"" ]; then
        fi
        
        # change gophers:// to gopher:// for now.
       -if match "$text" '^gophers://'; then
       -        text="${text#gophers://}"
       -        text="gopher://${text}"
       -fi
       +#if match "$text" '^gophers://'; then
       +#        text="${text#gophers://}"
       +#        text="gopher://${text}"
       +#fi
        
        # gopher protocol plumber
        if match "$text" '^(gopher|gophers)://'; then
       @@ -129,6 +129,8 @@ if match "$text" '^(gopher|gophers)://'; then
                elif match "$text" '\.(png|jpg|jpeg|webp|bmp)$' 'i'; then
                        image "$out"
                fi
       +elif match "$text" '^(ytdl)://'; then
       +        movie "$text"
        elif match "$text" '^(lbry)://'; then
                text=$("$HOME/.config/scripts/plumb/lbry.sh" "$text")
                movie "$text"