Proposing multiple changes #2
|
@ -0,0 +1,3 @@
|
||||||
|
install:
|
||||||
|
mkdir -p $(PREFIX)/bin
|
||||||
|
cp shelltube lib/* $(PREFIX)/bin/
|
93
README.md
93
README.md
|
@ -1,4 +1,4 @@
|
||||||
#Shelltube
|
![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
|
browse YouTube quickly, efficiently, and without the bloat
|
||||||
|
@ -23,65 +23,72 @@ Usage
|
||||||
Shelltube is quite simple to use; this tutorial will go over
|
Shelltube is quite simple to use; this tutorial will go over
|
||||||
the usage of the wrapper script, shelltube.sh.
|
the usage of the wrapper script, shelltube.sh.
|
||||||
When running the script, you'll see a prompt:
|
When running the script, you'll see a prompt:
|
||||||
\>\>
|
|
||||||
|
```
|
||||||
|
>>
|
||||||
|
```
|
||||||
|
|
||||||
In this prompt you can type any of the following commands:
|
In this prompt you can type any of the following commands:
|
||||||
(!) about
|
|
||||||
*View the about page.*
|
|
||||||
(cls) clear
|
|
||||||
*Clear the screen.*
|
|
||||||
(dl) download [URL]
|
|
||||||
*Download the selected/specified video.*
|
|
||||||
exit
|
|
||||||
*Exit Shelltube.*
|
|
||||||
(?) help
|
|
||||||
*Display this message.*
|
|
||||||
(md) metadata [URL]
|
|
||||||
*Display selected/specified video's MD.*
|
|
||||||
(/) search {term}
|
|
||||||
*Perform a search.*
|
|
||||||
(str) stream [URL]
|
|
||||||
*Stream the selected/specified video.*
|
|
||||||
(sel) video {URL}
|
|
||||||
*Select video based on URL or ID.*
|
|
||||||
|
|
||||||
In (parenthesis), smaller aliases for the commands are written.
|
| (short) command syntax | description |
|
||||||
In {curly brackets}, required arguments are written.
|
| --- | --- |
|
||||||
|
| (`!`) `about` | View the about page. |
|
||||||
|
| (`cls`) `clear` | Clear the screen. |
|
||||||
|
| (`dl`) `download [URL] ` | Download the selected/specified video. |
|
||||||
|
| `exit` | Exit Shelltube. |
|
||||||
|
| (`?`) `help` | Display this message. |
|
||||||
|
| (`md`) `metadata [URL]` | Display selected/specified video's metadata. |
|
||||||
|
| (`/`) `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.
|
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):
|
||||||
**A)** By selecting a video and then doing something with it
|
|
||||||
**B)** By doing something and specifying the video
|
|
||||||
|
|
||||||
Method A entails using either the "video" or "search" command
|
1. By selecting a video and then doing something with it
|
||||||
to select a video, which will then be displayed before the prompt
|
2. By doing something and specifying the video
|
||||||
like so:
|
|
||||||
$VIDEO-ID-HERE \>\>
|
Method A entails using either the `video` or `search`
|
||||||
When a video is selected, you use the "download", "stream", or
|
command to select a video, which will then be displayed
|
||||||
"metadata" commands without arguments to act on the video.
|
before the prompt like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
$VIDEO-ID-HERE >>
|
||||||
|
```
|
||||||
|
|
||||||
|
When a video is selected, you use the `download`, `stream`,
|
||||||
|
or `metadata` commands without arguments to act on the
|
||||||
|
video.
|
||||||
|
|
||||||
|
Method B entails just using the `download`, `stream`, or
|
||||||
|
`metadata` commands while using a URL or video ID as an
|
||||||
|
argument.
|
||||||
|
|
||||||
Method B entails just using the "download", "stream", or
|
|
||||||
"metadata" commands while using a URL or video ID as an argument.
|
|
||||||
For example:
|
For example:
|
||||||
\>\> download $VIDEO-ID-HERE
|
|
||||||
|
|
||||||
|
```
|
||||||
|
>> download $VIDEO-ID-HERE
|
||||||
|
```
|
||||||
|
|
||||||
You could opt to not use this interactive wrapper script and instead
|
You could opt to not use this interactive wrapper script and
|
||||||
just use the yt-down.sh, yt-search.sh, and yt-metadata.sh scripts
|
instead just use the `yt-down`, `yt-search`, and
|
||||||
on their own.
|
`yt-metadata` scripts on their own.
|
||||||
|
|
||||||
They are each pretty simple, and you can read their USAGE messages
|
They are each pretty simple, and you can read their USAGE
|
||||||
at the top of each script.
|
messages at the top of each script.
|
||||||
|
|
||||||
|
|
||||||
Licensing
|
Licensing
|
||||||
-----------
|
-----------
|
||||||
All of ST is released under the ISC license
|
All of ST is released under the
|
||||||
(https://opensource.org/licenses/ISC)
|
[ISC](https://opensource.org/licenses/ISC) license.
|
||||||
except for the yt-down.sh script, which is released under the GPLv2
|
|
||||||
(https://www.gnu.org/licenses/gpl-2.0.html)
|
Except for the `yt-down` script, which is released under the
|
||||||
|
[GPLv2](https://www.gnu.org/licenses/gpl-2.0.html).
|
||||||
|
|
||||||
|
|
||||||
Credit
|
Credit
|
||||||
--------
|
--------
|
||||||
jadedctrl wrote most of ST, but iluaster wrote almost all of
|
jadedctrl wrote most of ST, but iluaster wrote almost all of
|
||||||
yt-down.sh
|
`yt-down`
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
|
|
||||||
interactive_mode=0
|
interactive_mode=0
|
||||||
channel_file="/tmp/$(mktemp -u yt-channel_XXXXX)"
|
channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
|
||||||
|
|
||||||
# I really need to work out a better way to take flags.
|
# I really need to work out a better way to take flags.
|
||||||
# This is just awful.
|
# This is just awful.
|
||||||
|
@ -82,7 +82,7 @@ function get_input() {
|
||||||
row=0
|
row=0
|
||||||
|
|
||||||
# Now for displaying the search results
|
# Now for displaying the search results
|
||||||
temp_file="/tmp/$(mktemp -u yt-channel_XXXXX)"
|
temp_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
|
||||||
|
|
||||||
grep "href=\"\/watch?v=" $channel_file | grep "title=" | grep -v \
|
grep "href=\"\/watch?v=" $channel_file | grep "title=" | grep -v \
|
||||||
"<span class=\"yt-thumb-simple\"" > $temp_file
|
"<span class=\"yt-thumb-simple\"" > $temp_file
|
||||||
|
|
|
@ -21,7 +21,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
video_file="/tmp/$(mktemp -u yt-video_XXXXX)"
|
video_file="/tmp/$(mktemp -u yt-video_XXXXXX)"
|
||||||
if type "wget" &> /dev/null
|
if type "wget" &> /dev/null
|
||||||
then
|
then
|
||||||
wget -q https://youtube.com/watch?v=$id -O $video_file
|
wget -q https://youtube.com/watch?v=$id -O $video_file
|
||||||
|
|
|
@ -55,12 +55,12 @@ function get_input() {
|
||||||
# layout, this script'll break immediately, haha.
|
# layout, this script'll break immediately, haha.
|
||||||
# ... But at least we aren't using their API, right?
|
# ... But at least we aren't using their API, right?
|
||||||
|
|
||||||
search_file="/tmp/$(mktemp -u yt-search_XXXXX)"
|
search_file="/tmp/$(mktemp -u yt-search_XXXXXX)"
|
||||||
|
|
||||||
st-download https://youtube.com/results?search_query=$query $search_file
|
st-download https://youtube.com/results?search_query=$query $search_file
|
||||||
|
|
||||||
# Now for displaying the search results
|
# Now for displaying the search results
|
||||||
temp_file="/tmp/$(mktemp -u yt-result_XXXXX)"
|
temp_file="/tmp/$(mktemp -u yt-result_XXXXXX)"
|
||||||
grep "<a href=\"\/watch?v=" $search_file | grep -v "<span class=\"yt-thumb-simple\"" > $temp_file
|
grep "<a href=\"\/watch?v=" $search_file | grep -v "<span class=\"yt-thumb-simple\"" > $temp_file
|
||||||
item_num=0
|
item_num=0
|
||||||
cat $temp_file | while IFS='' read -r CUR_LINE
|
cat $temp_file | while IFS='' read -r CUR_LINE
|
||||||
|
|
244
shelltube
244
shelltube
|
@ -5,8 +5,9 @@
|
||||||
# Date: 2016-12-11
|
# Date: 2016-12-11
|
||||||
# Lisc: ISC
|
# Lisc: ISC
|
||||||
# Main: jadedctrl
|
# Main: jadedctrl
|
||||||
# Desc: Full-shell YT client that
|
# Desc: Full-shell YT client that avoids the YT API.
|
||||||
# avoids the YT API. #####################
|
Vers=0.4
|
||||||
|
#####################
|
||||||
|
|
||||||
# Roadmap:
|
# Roadmap:
|
||||||
# v1.0 - [ ] Playlist support
|
# v1.0 - [ ] Playlist support
|
||||||
|
@ -20,139 +21,124 @@
|
||||||
# [ ] Overall better interface
|
# [ ] Overall better interface
|
||||||
# [ ] Cli args as commands
|
# [ ] Cli args as commands
|
||||||
|
|
||||||
function search() {
|
search() {
|
||||||
output="/tmp/$(mktemp -u yt-search_XXXXX)"
|
output="$(mktemp -u /tmp/yt_XXXXXX)"
|
||||||
yt-search -i "$1" $output
|
yt-search -i "$1" "$output"
|
||||||
selected_video=$(cat $output)
|
selected_video="$(cat "$output")"
|
||||||
metadata
|
|
||||||
}
|
|
||||||
|
|
||||||
function channel() {
|
|
||||||
output="/tmp/$(mktemp -u yt-channel_XXXXX)"
|
|
||||||
if echo "$1" | grep "^UC" > /dev/null
|
|
||||||
then
|
|
||||||
yt-channel -ic "$1" $output
|
|
||||||
else
|
|
||||||
yt-channel -iu "$1" $output
|
|
||||||
fi
|
|
||||||
selected_video=$(cat $output)
|
|
||||||
metadata
|
|
||||||
}
|
|
||||||
|
|
||||||
function interactive() {
|
|
||||||
get_input
|
|
||||||
}
|
|
||||||
|
|
||||||
function about() {
|
|
||||||
printf '\033[0;35mShelltube v0.4.5\n'
|
|
||||||
printf '\033[0;32mDesc: \033[0;34mYT client written in shell.\n'
|
|
||||||
printf '\033[0;32mMain: \033[0;34mjadedml@openmailbox.org\n'
|
|
||||||
printf '\033[0;32mLisc: \033[0;34mISC; yt-down GPLv2\033[0m\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
function metadata() {
|
|
||||||
yt-meta "$selected_video"
|
yt-meta "$selected_video"
|
||||||
}
|
}
|
||||||
|
|
||||||
function download() {
|
channel() {
|
||||||
yt-down "$selected_video"
|
output="$(mktemp -u /tmp/yt-channel_XXXXXX)"
|
||||||
}
|
case "$1" in
|
||||||
|
UC* )
|
||||||
function stream() {
|
yt-channel -ic "$1" "$output"
|
||||||
yt-down -s "$selected_video"
|
;;
|
||||||
}
|
|
||||||
|
|
||||||
function get_input() {
|
|
||||||
printf '\033[0;34m%s \033[0;32m>>\033[0m ' "$selected_video"
|
|
||||||
read -r n
|
|
||||||
case $n in
|
|
||||||
help|'?')
|
|
||||||
help ; interactive ;;
|
|
||||||
download|dl)
|
|
||||||
download ; interactive ;;
|
|
||||||
metadata|md)
|
|
||||||
metadata ; interactive ;;
|
|
||||||
stream|str)
|
|
||||||
stream ; interactive ;;
|
|
||||||
about|'!')
|
|
||||||
about ; interactive ;;
|
|
||||||
clear|cls)
|
|
||||||
clear ; interactive ;;
|
|
||||||
exit)
|
|
||||||
rm /tmp/yt-* ; exit ;;
|
|
||||||
* )
|
* )
|
||||||
if [ "$n" ] && [ -z "${n%search *}" ]
|
yt-channel -iu "$1" "$output"
|
||||||
then
|
;;
|
||||||
search "${n#search }"
|
esac
|
||||||
interactive
|
selected_video="$(cat "$output")"
|
||||||
elif [ "$n" ] && [ -z "${n%/*}" ]
|
yt-meta "$selected_video"
|
||||||
then
|
}
|
||||||
search "${n#/}"
|
|
||||||
interactive
|
about() {
|
||||||
elif [ "$n" ] && [ -z "${n%channel *}" ]
|
printf '\033[35mShelltube v%s\033[m\n' "$Vers"
|
||||||
then
|
printf '\033[32mDesc: \033[0;34mYT client written in shell.\033[m\n'
|
||||||
channel "${n#channel }"
|
printf '\033[32mMain: \033[0;34mjadedml@openmailbox.org\033[m\n'
|
||||||
interactive
|
printf '\033[32mLisc: \033[0;34mISC; yt-down GPLv2\033[m\n'
|
||||||
elif [ "$n" ] && [ -z "${n%chan *}" ]
|
}
|
||||||
then
|
|
||||||
channel "${n#chan }"
|
help() {
|
||||||
interactive
|
printf "\
|
||||||
elif echo "$n" | grep "^video " > /dev/null
|
about | ! View the about page.
|
||||||
then
|
clear | cls Clear the screen.
|
||||||
if echo "$n" | grep "youtube.com"
|
download | dl Download the selected video.
|
||||||
then
|
exit | ctrl+c Exit Shelltube.
|
||||||
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
|
help | ? Display this message.
|
||||||
else
|
metadata | md Display selected video's metadata.
|
||||||
selected_video="$(echo "$n" | sed 's/video //')"
|
search | / Perform a search.
|
||||||
fi
|
channel | chan Show newest videos of a channel.
|
||||||
metadata
|
stream | str Stream the selected video.
|
||||||
interactive
|
video | sel | url Select video based on URL or ID.
|
||||||
elif echo "$n" | grep "^sel " > /dev/null
|
Note about usage:
|
||||||
then
|
Both 'video ID; download' and 'download ID' are valid. You don't need to
|
||||||
if echo "$n" | grep "youtube.com"
|
select a video to run commands on it, but if you use metadata, download, or
|
||||||
then
|
stream on an unselected video you must specify the ID or URL after the command.
|
||||||
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
|
"
|
||||||
else
|
}
|
||||||
selected_video="$(echo "$n" | sed 's/sel //')"
|
|
||||||
fi
|
parse() {
|
||||||
metadata
|
command="$1" argument="$2"
|
||||||
interactive
|
|
||||||
elif echo "$n" | grep "^url " > /dev/null
|
case "$command" in
|
||||||
then
|
help | '?' )
|
||||||
if echo "$n" | grep "youtube.com"
|
help
|
||||||
then
|
;;
|
||||||
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
|
search )
|
||||||
else
|
search "$argument"
|
||||||
selected_video="$(echo "$n" | sed 's/url //')"
|
;;
|
||||||
fi
|
/* )
|
||||||
metadata
|
search "${command#/}"
|
||||||
interactive
|
;;
|
||||||
else
|
channel )
|
||||||
get_input
|
channel "$argument"
|
||||||
fi
|
;;
|
||||||
|
chan )
|
||||||
|
channel "$argument"
|
||||||
|
;;
|
||||||
|
video | sel | url )
|
||||||
|
case "$argument" in
|
||||||
|
*youtube.com* )
|
||||||
|
selected_video="$argument"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
selected_video="$argument"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
yt-meta "$selected_video"
|
||||||
|
;;
|
||||||
|
metadata | md )
|
||||||
|
selected_video="${argument:-$selected_video}"
|
||||||
|
yt-meta "$selected_video"
|
||||||
|
;;
|
||||||
|
download | dl )
|
||||||
|
selected_video="${argument:-$selected_video}"
|
||||||
|
yt-down "$selected_video"
|
||||||
|
;;
|
||||||
|
stream | str )
|
||||||
|
selected_video="${argument:-$selected_video}"
|
||||||
|
yt-down -s "$selected_video"
|
||||||
|
;;
|
||||||
|
about | ! )
|
||||||
|
about
|
||||||
|
;;
|
||||||
|
clear | cls )
|
||||||
|
printf '\033[H\033[J'
|
||||||
|
;;
|
||||||
|
exit )
|
||||||
|
rm -f "/tmp/yt-$$"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
'' ) ;;
|
||||||
|
* )
|
||||||
|
printf 'unknown command: "%s"\ntry "help"\n' "$command"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "$#" -gt 0 ]
|
||||||
|
then
|
||||||
|
for arg in "$@"
|
||||||
|
do
|
||||||
|
parse "${arg%% *}" "${arg#* }"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
printf '\n \033[1mshell\033[41m Tube \033[0;1;30m v%s\033[m\n\n' "$Vers"
|
||||||
|
|
||||||
function help() {
|
while printf '\033[0;34m%s \033[0;32m>>\033[m ' "$selected_video"
|
||||||
echo "about | ! View the about page."
|
do
|
||||||
echo "clear | cls Clear the screen."
|
read -r command argument
|
||||||
echo "download | dl Download the selected video."
|
parse "$command" "$argument"
|
||||||
echo "exit | ctrl+c Exit Shelltube."
|
done
|
||||||
echo "help | ? Display this message."
|
fi
|
||||||
echo "metadata | md Display selected video's metadata."
|
|
||||||
echo "search | / Perform a search."
|
|
||||||
echo "channel | chan Show newest videos of a channel."
|
|
||||||
echo "stream | str Stream the selected video."
|
|
||||||
echo "video | sel | url Select video based on URL or ID."
|
|
||||||
echo "Note about usage:"
|
|
||||||
echo "Both 'video ID; download' and 'download ID' are valid."
|
|
||||||
echo "You don't need to select a video to run commands on it,"
|
|
||||||
echo "but if you use metadata, download, or stream on an"
|
|
||||||
echo "unselected video you must specify the ID or URL after the"
|
|
||||||
echo "command."
|
|
||||||
}
|
|
||||||
|
|
||||||
printf '\033[0;35mShelltube v0.4.5'
|
|
||||||
interactive
|
|
||||||
|
|
Reference in New Issue