commit a749b342914c850fad6cade6bcf462ff2766b186
parent 2a8b92dff677cbd5e28907461c307bd955ec89c1
Author: Jeff <dev@watertao.xyz>
Date: Sun, 1 Mar 2026 12:47:08 -0800
tao_url.sh: ytdlp/mpv and yt/* embedded commands
tao_url.sh
Built in yt/channel and yt/search commands for more easeful
configuration. Also added optional results limits for yt/channel or
yt/query calls:
yt/channel/50 #returns playlist limited to 50 results
Added a much more easeful and reasonable default command menu.
Diffstat:
3 files changed, 79 insertions(+), 46 deletions(-)
diff --git a/README b/README
@@ -320,7 +320,7 @@ tao_url.conf
### TAO_QUERY_ENG
Set the query url for search engine in tao_url.conf. Default:
- TAO_QUERY_ENG="https://ddg.gg?q="
+ TAO_QUERY_ENG="https://ddg.gg?q="
tao_opener.conf
@@ -340,22 +340,64 @@ Examples:
mpv %% mpv --msg-level=ffmpeg/video=error :: DL_OPT MEDIA_PLAYER TERM
nsxiv :: DL
+
+### yt/* and ytdlp/mpv
+
+Embedded tao_url.sh Commands:
+ ytdlp/mpv
+ yt/channel[/[0-9]+]
+ yt/query[/[0-9]+]
+
+Although a ytdlp/mpv and yt/* names can be customized for the menu, the
+command names cannot be changed. And tags do not apply and if added, will
+break the command.
+
+All yt/* commands can take a results limit, which takes the format of a
+number tacked onto the end of the command. Without an assigned limit,
+all is fetched. See "Acceptable" examples below.
+
+Acceptable:
+
+ ytdlp/mpv
+ ytdlp custom menu name %% ytdlp/mpv
+ yt channel limit 10 custom name %% yt/channel/10
+ yt/channel
+ yt search %% yt/query
+ yt search limit 80 results %% yt/query/80
+
+Unacceptable:
+
+ ytdlp/mpv :: tags that should not be here
+ yt custom menu name %% yt-wrong-name-for-ytdlp/mpv-command
+ yt custom menu name %% ytdlp/mpv :: tags that should not be here
+
+
### Opener Tags
-- DL: wget downloads url first, then program selected opens it.
-- DL_OPT: Same as DL, but offered as an interactive option. This is
- useful with mpv for example, where you can opt to not download and
- just run the url with mpv, whereupon the video is streamed. Or you
- can choose to download first then play locally. Each has their
- advantages.
-- MEDIA_PLAYER: Sets the program as the yt/mpv media player where the
- entire program call including options and flags is used to run the
- downloaded youtube video. Only one program is used with this tag, if
- multiple programs are tagged with this, the first in the list is
- used. If the tag isn't used, the default player is mpv.
-- TERM: Launch the program in a terminal. Text browsers such as w3m are
- fine candidates of this tag. If you wish to monitor the stdout/err
- msgs from any program, this tag is useful.
+DL
+
+wget downloads url first, then program selected opens it.
+
+DL_OPT
+
+Same as DL, but offered as an interactive option. This is useful with mpv for
+example, where you can opt to not download and just run the url with mpv,
+whereupon the video is streamed. Or you can choose to download first then play
+locally. Each has their advantages.
+
+MEDIA_PLAYER
+
+Sets the program as the yt/mpv media player where the entire program call
+including options and flags is used to run the downloaded youtube video. Only
+one program is used with this tag, if multiple programs are tagged with this,
+the first in the list is used. If the tag isn't used, the default player is
+mpv.
+
+TERM
+
+Launch the program in a terminal. Text browsers such as w3m are fine candidates
+of this tag. If you wish to monitor the stdout/err msgs from any program, this
+tag is useful.
Ethos: Computers and our Relationship with the Internet
@@ -428,23 +470,3 @@ a handful of utilities for the unix/linux user. There exist other tao
shells for a myriad of other tasks, and when the time comes that they
find comfort within themselves, they will walk out the front door as
these shells have done and join the world of open source.
-
-
-TECHNICAL NOTES
----------------
-### tao_opener.conf - yt/mpv menu name customization
-
-Although a yt/mpv name can be customized for the menu, the command
-cannot be changed. And tags do not apply and if added, will break the
-command:
-
-Acceptable:
-
- yt/mpv
- yt custom menu name %% yt/mpv
-
-Unacceptable:
-
- yt/mpv :: tags that should not be here
- yt custom menu name %% yt-wrong-name-for-yt/mpv-command
- yt custom menu name %% yt/mpv :: tags that should not be here
diff --git a/tao_url.sh b/tao_url.sh
@@ -48,6 +48,7 @@ qfile="${cdir}/query"
bfile="${cdir}/bookmark"
hfile="${cdir}/history"
w3mh="$HOME/.w3m/history"
+ytqry_cmd="tao_youtube_query.sh"
noterm=0
mk_ofile()
@@ -58,12 +59,13 @@ w3m :: TERM
firefox
links :: TERM
surf
-ytdlp/mpv
-yt channel (50) %% tao_youtube_query.sh -c
-yt channel (all) %% tao_youtube_query.sh -c -a
-yt search %% tao_youtube_query.sh -q
+yt download > play %% ytdlp/mpv
+a/v download > play %% mpv --msg-level=all=status,ffmpeg/video=error :: DL MEDIA_PLAYER TERM
+a/v/yt stream %% mpv --msg-level=all=status,ffmpeg/video=error :: TERM
+yt channel (20) %% yt/channel/20
+yt channel (all) %% yt/channel/all
+yt search %% yt/query
yank %% tao_copy.sh
-mpv %% mpv --msg-level=all=status,ffmpeg/video=error :: DL_OPT MEDIA_PLAYER TERM
zathura :: DL
nsxiv :: DL
bookmark
@@ -158,7 +160,17 @@ file_action()
cu
fi
- [ "$p" != "tao_youtube_query.sh -q" ] && query_stage
+ if [ "${p%%/*}" = "yt" ]; then
+ a="${p#*/}"
+ if [ "${a%%/*}" = "channel" ]; then
+ [ "${a##*/}" = "all" ] && \
+ p="$ytqry_cmd -c -a" || \
+ p="$ytqry_cmd -c -l ${a##*/}"
+ fi
+ [ "${a%%/*}" = "query" ] && p="$ytqry_cmd -q -l "${a##*/}""
+ else
+ [ $ft -eq 3 ] && query_stage
+ fi
# download-then-views first
prnt "$t" | grep -q "DL" && dl_then_view
@@ -224,7 +236,6 @@ input_remote()
query_stage()
{
- [ $ft -ne 3 ] && return 0
# Encode the search string (i.e. the rest of q). xxd was formerly used
# here, but xxd is part of vim packages on some systems, whereas od is
# ubiquitous. A search script that breaks if someone accidentally removes
diff --git a/tao_youtube_query.sh b/tao_youtube_query.sh
@@ -21,7 +21,7 @@
# Defaults (fetching latest from channels list)
typ="d"
-l=10
+l_dflt=50; l=$l_dflt
pts_title="Fetching latest channel videos..."
yt_prnt_opt="%(upload_date)s @ %(playlist_channel)s > %(title)s < ( %(view_count)s ) [ %(duration_string)s ] %(webpage_url)s"
yt_url="-a -"
@@ -138,20 +138,20 @@ runthething()
tao_url.sh -r "${u##* }" 2>$dn && return 0
}
-a=; while getopts "acq" a
+a=; while getopts "l:acq" a
do
case $a in
+ l) l=$OPTARG
+ prnt "$l" | grep -q '^[0-9]\+$' || l=$l_dflt ;;
a)
l=10000 ;;
c)
typ="c"
- l=100
pts_title="Fetching channel videos >"
yt_dm_title="channel videos"
yt_prnt_opt="%(upload_date)s > %(title)s < ( %(view_count)s ) [ %(duration_string)s ] %(webpage_url)s" ;;
q)
typ="q"
- l=100
pts_title="YT query >"
yt_dm_title="query results"
yt_prnt_opt="%(upload_date)s @ %(channel)s > %(title)s < (%(view_count)s) [ %(duration_string)s ] %(webpage_url)s" ;;