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
exit
fi
test $n -ge 0
if [ $? -gt 1 ]
if [ "$n" == "*" ]
then
cat $temp_file | while IFS='' read -r CUR_LINE
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
echo "Bad input, mate. Type in a valid number or 'exit'."
get_input

View File

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

View File

@ -5,7 +5,7 @@
# Lisc: ISC
# Main: jadedctrl
# Desc: Full-shell YT client that avoids the YT API.
Vers=0.5
Vers=0.5.1
#####################
# Roadmap:
@ -39,11 +39,11 @@ fi
search() {
output="$(mktemp -u /tmp/yt_XXXXXX)"
yt-search -i "$1" "$output"
if grep "^PL" "$output" > /dev/null
if sed -n ${1}p "$output" | grep "^PL" > /dev/null
then
playlist "$(cat "$output")"
playlist "$(sed -n ${1}p "$output")"
else
selected_video="$(cat "$output")"
selected_video="$(sed -n ${1}p "$output")"
yt-meta "$selected_video"
fi
}
@ -65,7 +65,7 @@ channel() {
yt-channel -iu "$1" "$output"
;;
esac
selected_video="$(cat "$output")"
selected_video="$(sed -n 1p "$output")"
yt-meta "$selected_video"
}
@ -89,6 +89,10 @@ search | / Perform a search.
channel | chan Show newest videos of a channel.
stream | str Stream the selected video.
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:
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
@ -157,13 +161,17 @@ parse() {
dqueue | dq )
for LINE in $(cat /tmp/yt-queue)
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
;;
squeue | sq )
for LINE in $(cat /tmp/yt-queue)
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
;;
about | ! )