diff --git a/README.md b/README.md index dbf2750..9fb50de 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ ![Shelltube](https://cloud.githubusercontent.com/assets/7250745/21452795/52fcd6ea-c901-11e6-871b-bd646f2d7c49.png) -Shelltube is a collection of (pretty POSIX) shell scripts to +shellTube is a collection of (pretty POSIX) shell scripts to browse YouTube quickly, efficiently, and without the bloat most command-line clients require. -Shelltube is written in pure shell; its only dependencies +shellTube is written in pure shell; its only dependencies are any modern shell (pdksh, bash, zsh), curl/wget, and vlc/mplayer/kaffeine. @@ -12,7 +12,7 @@ Even these dependencies, though, can easily be changed. If, for example, you don't have vlc, you can just modify a single line and be good-to-go using another player. -Also, Shelltube doesn't use the YouTube API at all. This +Also, shellTube doesn't use the YouTube API at all. This avoids the annoying red-tapey stuff that goes with it -- IDs, registration, quotas -- but has some disadvantages. We'll power through the downsides, though! :) @@ -20,8 +20,8 @@ power through the downsides, though! :) Usage ------- -Shelltube is quite simple to use; this tutorial will go over -the usage of the wrapper script, shelltube.sh. +shellTube is quite simple to use; this tutorial will go over +the usage of the wrapper script, `shelltube`. When running the script, you'll see a prompt: ``` @@ -38,13 +38,14 @@ In this prompt you can type any of the following commands: | `exit` | Exit Shelltube. | | (`?`) `help` | Display this message. | | (`md`) `metadata [URL]` | Display selected/specified video's metadata. | +| (`//`) `playlist URL` `playlist ID` | View playlist based on `URL` or `ID`. | | (`/`) `search TERM` | Perform a search for `TERM`. | | (`str`) `stream [URL]` | Stream the selected/specified video. | | (`sel`) `video URL` `video ID` | Select video based on `URL` or `ID`. | In [brackets], optional arguments are written. -You can use Shelltube in one of two ways (or both): +You can use shellTube in one of two ways (or both): 1. By selecting a video and then doing something with it 2. By doing something and specifying the video @@ -86,9 +87,3 @@ All of ST is released under the Except for the `yt-down` script, which is released under the [GPLv2](https://www.gnu.org/licenses/gpl-2.0.html). - - -Credit --------- -jadedctrl wrote most of ST, but iluaster wrote almost all of -`yt-down` diff --git a/lib/yt-playlist b/lib/yt-playlist new file mode 100755 index 0000000..244c9aa --- /dev/null +++ b/lib/yt-playlist @@ -0,0 +1,150 @@ +##################### +# 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 "