Ĉi tiu deponejo arĥiviĝis je 2024-01-29. Vi povas vidi kaj elŝuti dosierojn, sed ne povas puŝi nek raporti problemojn nek tirpeti.
shellTube/shelltube

159 lines
4.5 KiB
Plaintext
Raw Normal View History

2016-12-22 19:14:27 -06:00
#!/bin/sh
2016-12-11 19:33:57 -06:00
####################
# Name: shelltube.sh
# Date: 2016-12-11
# Lisc: ISC
# Main: jadedctrl
# Desc: Full-shell YT client that
2016-12-23 11:12:07 -06:00
# avoids the YT API. #####################
2016-12-11 19:33:57 -06:00
2016-12-22 19:14:27 -06:00
# Roadmap:
# v1.0 - [ ] Playlist support
# [X] Channel support
# [ ] Audio dl/stream
# [ ] Show related videos
# [ ] Channel & Playlist search
# [ ] Search filters
# [ ] Search & Channel sort-by
# [ ] Config video player, etc
# [ ] Overall better interface
# [ ] Cli args as commands
2016-12-11 19:33:57 -06:00
function search() {
2016-12-23 11:12:07 -06:00
output="/tmp/$(mktemp -u yt-search_XXXXX)"
2016-12-22 19:14:27 -06:00
yt-search -i "$1" $output
selected_video=$(cat $output)
metadata
}
function channel() {
2016-12-23 11:12:07 -06:00
output="/tmp/$(mktemp -u yt-channel_XXXXX)"
2016-12-22 19:14:27 -06:00
if echo "$1" | grep "^UC" > /dev/null
then
yt-channel -ic "$1" $output
else
yt-channel -iu "$1" $output
fi
2016-12-11 19:33:57 -06:00
selected_video=$(cat $output)
metadata
}
function interactive() {
get_input
}
function about() {
2016-12-23 11:12:07 -06:00
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'
2016-12-11 19:33:57 -06:00
}
function metadata() {
2016-12-22 19:14:27 -06:00
yt-meta "$selected_video"
2016-12-11 19:33:57 -06:00
}
function download() {
2016-12-22 19:14:27 -06:00
yt-down "$selected_video"
2016-12-11 19:33:57 -06:00
}
function stream() {
2016-12-22 19:14:27 -06:00
yt-down -s "$selected_video"
2016-12-11 19:33:57 -06:00
}
function get_input() {
2016-12-23 11:12:07 -06:00
printf '\033[0;34m%s \033[0;32m>>\033[0m ' "$selected_video"
2016-12-11 19:33:57 -06:00
read -r n
2016-12-23 11:12:07 -06:00
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 *}" ]
then
search "${n#search }"
interactive
elif [ "$n" ] && [ -z "${n%/*}" ]
then
search "${n#/}"
interactive
elif [ "$n" ] && [ -z "${n%channel *}" ]
then
channel "${n#channel }"
interactive
elif [ "$n" ] && [ -z "${n%chan *}" ]
then
channel "${n#chan }"
interactive
elif echo "$n" | grep "^video " > /dev/null
then
if echo "$n" | grep "youtube.com"
then
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
else
selected_video="$(echo "$n" | sed 's/video //')"
fi
metadata
interactive
elif echo "$n" | grep "^sel " > /dev/null
then
if echo "$n" | grep "youtube.com"
then
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
else
selected_video="$(echo "$n" | sed 's/sel //')"
fi
metadata
interactive
elif echo "$n" | grep "^url " > /dev/null
then
if echo "$n" | grep "youtube.com"
then
selected_video="$(echo "$n" | sed 's/.*watch?v=//')"
else
selected_video="$(echo "$n" | sed 's/url //')"
fi
metadata
interactive
else
get_input
fi
;;
esac
2016-12-11 19:33:57 -06:00
}
2016-12-23 11:12:07 -06:00
2016-12-11 19:33:57 -06:00
function help() {
echo "about | ! View the about page."
echo "clear | cls Clear the screen."
echo "download | dl Download the selected video."
echo "exit | ctrl+c Exit Shelltube."
echo "help | ? Display this message."
echo "metadata | md Display selected video's metadata."
echo "search | / Perform a search."
2016-12-22 19:14:27 -06:00
echo "channel | chan Show newest videos of a channel."
2016-12-11 19:33:57 -06:00
echo "stream | str Stream the selected video."
2016-12-22 19:14:27 -06:00
echo "video | sel | url Select video based on URL or ID."
2016-12-11 19:33:57 -06:00
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."
}
2016-12-23 11:12:07 -06:00
printf '\033[0;35mShelltube v0.4.5'
2016-12-11 19:33:57 -06:00
interactive