1
0

watch_latest

This commit is contained in:
dtb 2022-11-04 22:14:46 -04:00
parent 885e6c199d
commit b315b02a59

View File

@ -20,52 +20,9 @@ list_channels(){
done
}
latin(){
while str isvalue "$1"
do xq '.feed.pig' <"$1"
shift
done
}
stow(){
while str isvalue "$1"
do pig_fetch "$1" | xq -x "$(
date '+%Y-%m-%dT%T' \
| xargs printf '
. * { feed: { pig: {
feed_url: "%b",
pet_sound: "choo",
stow_date: "%b",
version: "0"
} } }' "$1" \
)" >"$(pig_pen)/$(pig_name "$1")"
shift
done
}
usage(){
printf "\
Usage: %s
list_channels
list_videos [channel name]
listen [video URL]
refresh (channel name...)
subscribe [channel URL]
watch [video URL]
" "$argv0" 1>&2
}
case "$1" in
list_channels)
! str isvalue "$2" \
|| usage
list_channels | sort
;;
list_videos) # do something with youtube-dl?
str isvalue "$2" \
|| usage
list_videos(){
list_channels \
| grep "$2" \
| grep "$1" \
| cut -f 2 \
| xargs xq \
'reduce .feed.entry[] as $item (
@ -78,6 +35,62 @@ list_videos) # do something with youtube-dl?
-e 's/\": \"/ /g' \
-e 's/^ \"//g' \
-e 's/\"\,$//g' # this is really hacky
}
latin(){
xq '.feed.pig' <"$1"
}
stow(){
pig_fetch "$1" | xq -x "$(
date '+%Y-%m-%dT%T' \
| xargs printf '
. * { feed: { pig: {
feed_url: "%b",
pet_sound: "choo",
stow_date: "%b",
version: "0"
} } }' "$1" \
)" >"$(pig_pen)/$(pig_name "$1")"
}
watch(){
youtube-dl -F "$1"
printf "Pick a format [22]: "
input="$(head -n 1 | tr -d '\n')"
str isalnum "$input" \
&& str isdigit $input \
|| input=22 \
&& youtube-dl -f $input "$1" -o - \
| mpv -
}
usage(){
printf "\
Usage: %s
list_channels
list_videos [channel name...]
listen [video URL]
refresh (channel name...)
subscribe [channel URL...]
watch [video URL...]
watch_latest [channel name...]
" "$argv0" 1>&2
}
case "$1" in
list_channels)
! str isvalue "$2" \
|| usage
list_channels | sort
;;
list_videos) # do something with youtube-dl?
str isvalue "$2" \
|| usage
while str isvalue "$2"
do list_videos "$2"
shift
done
;;
listen)
str isvalue "$2" \
@ -119,8 +132,18 @@ watch) # needs work
str isvalue "$2" \
|| usage
while str isvalue "$2"
do youtube-dl "$2" -f 18 -o - \
| mpv -
do watch "$2"
done
;;
watch_latest)
str isvalue "$2" \
|| usage
while str isvalue "$2"
do watch "$( \
list_videos "$2" \
| head -n 1 \
| cut -f 1 \
)"
shift
done
;;