##################### # Name: yt-playlist # Lisc: ISC # Main: jadedctrl # Desc: List a playlist's videos # in easy-to-read and easy-to # -parse results ##################### # Usage: yt-playlist "$playlist_ID" if [ -e $HOME/.config/shelltube ] then . $HOME/.config/shelltube else results=21 fi if [ -e "./lib/yt-meta" ] then alias yt-channel="./lib/yt-channel" alias yt-search="./lib/yt-down" alias yt-meta="./lib/yt-meta" alias yt-search="./lib/yt-search" alias yt-down="./lib/yt-channel" alias st-download="./lib/st-download" alias st-video="./lib/st-video" fi row=0 if [ "$1" == "-i" ] then interactive_mode=1 plist="$(echo "$2" | sed 's/ /+/g')" output="$3" else interactive_mode=0 plist="$(echo "$1" | sed 's/ /+/g')" fi function get_input() { printf '\033[0;32m>>>\033[0m ' read -r n if [ "$n" == "exit" ] then exit fi test $n -ge 0 &> /dev/null if [ $? -gt 1 ] then echo "Bad input, mate. Type in a valid number or 'exit'." get_input elif [ $n -gt 20 ] then echo "Out of range. Type in a valid number or 'exit'." get_input elif [ $n -gt 0 ] && [ $n -lt 20 ] then sed -n ${n}p $temp_file | sed 's/.*data-video-id="//' | sed 's/".*//' > $output else echo "Bad input, mate. Type in a valid number or 'exit'." get_input fi } # If Google adds any extra features or changes the webpage # layout, this script'll break immediately, haha. # ... But at least we aren't using their API, right? plist_file="/tmp/$(mktemp -u yt-search_XXXXXX)" st-download https://youtube.com/playlist?list=$plist $plist_file # Now for displaying the search results temp_file="/tmp/$(mktemp -u yt-result_XXXXXX)" grep "