Wildcard support

This commit is contained in:
Jaidyn Ann 2017-01-08 00:10:36 -06:00
parent 73af486c10
commit 8a7d020000
3 changed files with 34 additions and 18 deletions

View File

@ -75,10 +75,15 @@ get_input() {
then then
exit exit
fi fi
if [ "$n" == "*" ]
test $n -ge 0 then
cat $temp_file | while IFS='' read -r CUR_LINE
if [ $? -gt 1 ] do
echo "$CUR_LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//' >> $output
done
cp $output /tmp/yt-queue
# test $n -ge 0
elif [ $? -gt 1 ]
then then
echo "Bad input, mate. Type in a valid number or 'exit'." echo "Bad input, mate. Type in a valid number or 'exit'."
get_input get_input

View File

@ -4,8 +4,7 @@
# Lisc: ISC # Lisc: ISC
# Main: jadedctrl # Main: jadedctrl
# Desc: Search YT videos and display # Desc: Search YT videos and display
# in easy-to-read and easy-to # in easy-to-read and easy-to # -parse results
# -parse results
##################### #####################
# Usage: yt-search.sh "$search_string" # Usage: yt-search.sh "$search_string"
@ -47,11 +46,15 @@ function get_input() {
if [ "$n" == "exit" ] if [ "$n" == "exit" ]
then then
exit exit
fi elif [ "$n" == "*" ]
then
test $n -ge 0 &> /dev/null cat $temp_file | while IFS='' read -r CUR_LINE
do
if [ $? -gt 1 ] echo "$CUR_LINE" | sed 's/.*<a href="\/watch?v=//' | sed 's/".*//' >> $output
done
cp $output /tmp/yt-queue
#test $n -ge 0 &> /dev/null
elif [ $? -gt 1 ]
then then
echo "Bad input, mate. Type in a valid number or 'exit'." echo "Bad input, mate. Type in a valid number or 'exit'."
get_input get_input

View File

@ -5,7 +5,7 @@
# Lisc: ISC # Lisc: ISC
# Main: jadedctrl # Main: jadedctrl
# Desc: Full-shell YT client that avoids the YT API. # Desc: Full-shell YT client that avoids the YT API.
Vers=0.5 Vers=0.5.1
##################### #####################
# Roadmap: # Roadmap:
@ -39,11 +39,11 @@ fi
search() { search() {
output="$(mktemp -u /tmp/yt_XXXXXX)" output="$(mktemp -u /tmp/yt_XXXXXX)"
yt-search -i "$1" "$output" yt-search -i "$1" "$output"
if grep "^PL" "$output" > /dev/null if sed -n ${1}p "$output" | grep "^PL" > /dev/null
then then
playlist "$(cat "$output")" playlist "$(sed -n ${1}p "$output")"
else else
selected_video="$(cat "$output")" selected_video="$(sed -n ${1}p "$output")"
yt-meta "$selected_video" yt-meta "$selected_video"
fi fi
} }
@ -65,7 +65,7 @@ channel() {
yt-channel -iu "$1" "$output" yt-channel -iu "$1" "$output"
;; ;;
esac esac
selected_video="$(cat "$output")" selected_video="$(sed -n 1p "$output")"
yt-meta "$selected_video" yt-meta "$selected_video"
} }
@ -89,6 +89,10 @@ search | / Perform a search.
channel | chan Show newest videos of a channel. channel | chan Show newest videos of a channel.
stream | str Stream the selected video. stream | str Stream the selected video.
video | sel | url Select video based on URL or ID. video | sel | url Select video based on URL or ID.
queue | lq List videos in the queue.
squeue | sq Stream all videos in the queue.
dqueue | dq Download all videos in the queue.
Note about usage: Note about usage:
Both 'video ID; download' and 'download ID' are valid. You don't need to Both 'video ID; download' and 'download ID' are valid. You don't need to
select a video to run commands on it, but if you use metadata, download, or select a video to run commands on it, but if you use metadata, download, or
@ -157,13 +161,17 @@ parse() {
dqueue | dq ) dqueue | dq )
for LINE in $(cat /tmp/yt-queue) for LINE in $(cat /tmp/yt-queue)
do do
yt-down "$LINE" yt-down -D "$LINE"
grep -v "$LINE" /tmp/yt-queue > /tmp/yt-queue.tmp
mv /tmp/yt-queue.tmp /tmp/yt-queue
done done
;; ;;
squeue | sq ) squeue | sq )
for LINE in $(cat /tmp/yt-queue) for LINE in $(cat /tmp/yt-queue)
do do
yt-down -s "$LINE" yt-down -S "$LINE"
grep -v "$LINE" /tmp/yt-queue > /tmp/yt-queue.tmp
mv /tmp/yt-queue.tmp /tmp/yt-queue
done done
;; ;;
about | ! ) about | ! )