From 8a7d0200008524d1a3ec62c4b80886100d64c466 Mon Sep 17 00:00:00 2001 From: Jade Levesque Date: Sun, 8 Jan 2017 00:10:36 -0600 Subject: [PATCH] Wildcard support --- lib/yt-channel | 13 +++++++++---- lib/yt-search | 17 ++++++++++------- shelltube | 22 +++++++++++++++------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/yt-channel b/lib/yt-channel index c215354..7a36b59 100755 --- a/lib/yt-channel +++ b/lib/yt-channel @@ -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 diff --git a/lib/yt-search b/lib/yt-search index 4f16c9e..56ec4e8 100755 --- a/lib/yt-search +++ b/lib/yt-search @@ -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/.*> $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 diff --git a/shelltube b/shelltube index 6ec960b..a9c1a8b 100755 --- a/shelltube +++ b/shelltube @@ -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 | ! )