Ĉ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
Bash
Executable File

#!/bin/sh
####################
# Name: shelltube.sh
# Date: 2016-12-11
# Lisc: ISC
# Main: jadedctrl
# Desc: Full-shell YT client that
# avoids the YT API. #####################
# 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
function search() {
output="/tmp/$(mktemp -u yt-search_XXXXX)"
yt-search -i "$1" $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"
}
function download() {
yt-down "$selected_video"
}
function stream() {
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 *}" ]
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
}
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."
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