Sedate Shellcheck a little
This commit is contained in:
parent
2fa5a7d3b5
commit
cdb7481b55
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#####################
|
#####################
|
||||||
# Name: st-download.sh
|
# Name: st-download.sh
|
||||||
# Date: 2016-12-22
|
|
||||||
# Lisc: ISC
|
# Lisc: ISC
|
||||||
# Main: jadedctrl
|
# Main: jadedctrl
|
||||||
# Desc: No beer and no TV
|
# Desc: No beer and no TV
|
||||||
|
@ -10,12 +9,12 @@
|
||||||
# Cxu ne?
|
# Cxu ne?
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
if test -z $download_cmd
|
if test -z "$download_cmd"
|
||||||
then
|
then
|
||||||
if type "wget" &> /dev/null
|
if command -v wget > /dev/null
|
||||||
then
|
then
|
||||||
wget -q "$1" -O "$2"
|
wget -q "$1" -O "$2"
|
||||||
elif type "curl" &> /dev/null
|
elif command -v curl > /dev/null
|
||||||
then
|
then
|
||||||
curl -s "$1" -o "$2"
|
curl -s "$1" -o "$2"
|
||||||
fi
|
fi
|
||||||
|
|
10
lib/st-video
10
lib/st-video
|
@ -9,17 +9,17 @@
|
||||||
# dsfgbvesrht fd
|
# dsfgbvesrht fd
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
if [ -e $HOME/.config/shelltube ]
|
if [ -e "$HOME/.config/shelltube" ]
|
||||||
then
|
then
|
||||||
. $HOME/.config/shelltube
|
. "$HOME/.config/shelltube"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z $player_cmd
|
if test -z "$player_cmd"
|
||||||
then
|
then
|
||||||
if type "vlc" &> /dev/null
|
if command -v vlc > /dev/null
|
||||||
then
|
then
|
||||||
vlc "${1}"
|
vlc "${1}"
|
||||||
elif type "mplayer" &> /dev/null
|
elif command -v mplayer > /dev/null
|
||||||
then
|
then
|
||||||
mplayer "${1}"
|
mplayer "${1}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
#####################
|
#####################
|
||||||
# Name: yt-channel.sh
|
# Name: yt-channel.sh
|
||||||
# Date: 2016-12-22
|
|
||||||
# Lisc: ISC
|
# Lisc: ISC
|
||||||
# Main: jadedctrl
|
# Main: jadedctrl
|
||||||
# Desc: Display a channel's videos
|
# Desc: Display a channel's videos
|
||||||
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
# Usage: yt-channel.sh [-uci] userid||channel
|
# Usage: yt-channel.sh [-uci] userid||channel
|
||||||
|
|
||||||
if [ -e $HOME/.config/shelltube ]
|
if [ -e "$HOME/.config/shelltube" ]
|
||||||
then
|
then
|
||||||
. $HOME/.config/shelltube
|
. "$HOME/.config/shelltube"
|
||||||
else
|
else
|
||||||
results=21
|
results=21
|
||||||
fi
|
fi
|
||||||
|
@ -25,27 +25,27 @@ channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
|
||||||
# ... I'll cross that bridge later.
|
# ... I'll cross that bridge later.
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" == "-u" ]
|
if [ "$1" = "-u" ]
|
||||||
then
|
then
|
||||||
type="user"
|
type="user"
|
||||||
st-download https://youtube.com/user/$2/videos $channel_file
|
st-download "https://youtube.com/user/$2/videos" "$channel_file"
|
||||||
elif [ "$1" == "-iu" ]
|
elif [ "$1" = "-iu" ]
|
||||||
then
|
then
|
||||||
output="$3"
|
output="$3"
|
||||||
interactive_mode=1
|
interactive_mode=1
|
||||||
type="user"
|
type="user"
|
||||||
st-download https://youtube.com/user/$2/videos $channel_file
|
st-download "https://youtube.com/user/$2/videos" "$channel_file"
|
||||||
elif [ "$1" == "-c" ]
|
elif [ "$1" = "-c" ]
|
||||||
then
|
then
|
||||||
type="channel"
|
type="channel"
|
||||||
st-download https://youtube.com/channel/$2/videos $channel_file
|
st-download "https://youtube.com/channel/$2/videos" "$channel_file"
|
||||||
elif [ "$1" == "-ic" ]
|
elif [ "$1" = "-ic" ]
|
||||||
then
|
then
|
||||||
output="$3"
|
output="$3"
|
||||||
interactive_mode=1
|
interactive_mode=1
|
||||||
type="channel"
|
type="channel"
|
||||||
st-download https://youtube.com/channel/$2/videos $channel_file
|
st-download "https://youtube.com/channel/$2/videos" "$channel_file"
|
||||||
elif [ "$1" == "-uc" ] || [ -k "$2" ]
|
elif [ "$1" = "-uc" ] || [ -k "$2" ]
|
||||||
then
|
then
|
||||||
echo "Usage: yt-channel.sh [-uci] userid||channel [output]"
|
echo "Usage: yt-channel.sh [-uci] userid||channel [output]"
|
||||||
echo "Make sure to use either the -u flag or the -c flag--"
|
echo "Make sure to use either the -u flag or the -c flag--"
|
||||||
|
@ -56,16 +56,16 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function get_input() {
|
get_input() {
|
||||||
printf '\033[0;32m>>>\033[0m '
|
printf '\033[0;32m>>>\033[0m '
|
||||||
read -r n
|
read -r n
|
||||||
|
|
||||||
if [ "$n" == "exit" ]
|
if [ "$n" = "exit" ]
|
||||||
then
|
then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test $n -ge 0 &> /dev/null
|
test $n -ge 0
|
||||||
|
|
||||||
if [ $? -gt 1 ]
|
if [ $? -gt 1 ]
|
||||||
then
|
then
|
||||||
|
@ -77,7 +77,7 @@ function get_input() {
|
||||||
get_input
|
get_input
|
||||||
elif [ $n -gt 0 ] && [ $n -lt 20 ]
|
elif [ $n -gt 0 ] && [ $n -lt 20 ]
|
||||||
then
|
then
|
||||||
sed -n ${n}p $temp_file | sed 's/.*href="\/watch?v=//' | sed 's/".*//' > $output
|
sed -n "${n}p" "$temp_file" | sed 's/.*href="\/watch?v=//' | sed 's/".*//' > "$output"
|
||||||
else
|
else
|
||||||
echo "Bad input, mate. Type in a valid number or 'exit'."
|
echo "Bad input, mate. Type in a valid number or 'exit'."
|
||||||
get_input
|
get_input
|
||||||
|
@ -90,15 +90,15 @@ row=0
|
||||||
# Now for displaying the search results
|
# Now for displaying the search results
|
||||||
temp_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
|
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"
|
||||||
item_num=0
|
item_num=0
|
||||||
cat $temp_file | while IFS='' read -r CUR_LINE
|
cat "$temp_file" | while IFS='' read -r CUR_LINE
|
||||||
do
|
do
|
||||||
item_num=$(($item_num+1))
|
item_num=$((item_num+1))
|
||||||
LINE="$(echo $CUR_LINE | sed 's/<span class=\"yt-badge \" >.*//')"
|
LINE="$(echo "$CUR_LINE" | sed 's/<span class=\"yt-badge \" >.*//')"
|
||||||
LINE="$(echo $LINE | sed 's/views<\/li>.*//')"
|
LINE="$(echo "$LINE" | sed 's/views<\/li>.*//')"
|
||||||
LINE="$(echo $LINE | sed 's/title="Verified"//')"
|
LINE="$(echo "$LINE" | sed 's/title="Verified"//')"
|
||||||
|
|
||||||
if [ $row -eq 1 ]
|
if [ $row -eq 1 ]
|
||||||
then
|
then
|
||||||
|
@ -153,8 +153,8 @@ do
|
||||||
while [ $i -lt 9 ]
|
while [ $i -lt 9 ]
|
||||||
do
|
do
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
char=$(echo $duration | cut -c$i)
|
char=$(echo "$duration" | cut -c$i)
|
||||||
if [ -z $char ]
|
if [ -z "$char" ]
|
||||||
then
|
then
|
||||||
printf ' '
|
printf ' '
|
||||||
else
|
else
|
||||||
|
@ -172,4 +172,4 @@ fi
|
||||||
|
|
||||||
printf '\033[0m'
|
printf '\033[0m'
|
||||||
|
|
||||||
rm $temp_file
|
rm "$temp_file"
|
||||||
|
|
53
lib/yt-down
53
lib/yt-down
|
@ -11,7 +11,7 @@
|
||||||
# Based on https://github.com/iluaster/Youtube_downloader
|
# Based on https://github.com/iluaster/Youtube_downloader
|
||||||
# Usage: yt-download.sh $video_id
|
# Usage: yt-download.sh $video_id
|
||||||
|
|
||||||
if [ "$1" == "-s" ]
|
if [ "$1" = "-s" ]
|
||||||
then
|
then
|
||||||
stream_mode=1
|
stream_mode=1
|
||||||
id=$2
|
id=$2
|
||||||
|
@ -22,8 +22,8 @@ fi
|
||||||
|
|
||||||
if echo "$id" | grep "youtube.com"
|
if echo "$id" | grep "youtube.com"
|
||||||
then
|
then
|
||||||
id="$(echo $id | sed 's/.*video_id=//')"
|
id="$(echo "$id" | sed 's/.*video_id=//')"
|
||||||
elif [ -z $id ]
|
elif [ -z "$id" ]
|
||||||
then
|
then
|
||||||
echo "No video specified."
|
echo "No video specified."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -33,23 +33,33 @@ fi
|
||||||
|
|
||||||
name="http://www.youtube.com/get_video_info?video_id=$id"
|
name="http://www.youtube.com/get_video_info?video_id=$id"
|
||||||
|
|
||||||
declare -i line=0
|
declare -i line=0 2> /dev/null
|
||||||
|
|
||||||
function select_option ()
|
if $? 2> /dev/null
|
||||||
|
then
|
||||||
|
echo > /dev/null
|
||||||
|
else
|
||||||
|
line=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
select_option ()
|
||||||
{
|
{
|
||||||
echo "Formats:"
|
echo "Formats:"
|
||||||
for i in $(cat /tmp/video_type_option.txt)
|
cat /tmp/video_type_option.txt | while IFS='' read -r i
|
||||||
do
|
do
|
||||||
line=$((line+1))
|
line=$((line+1))
|
||||||
|
# Replace this pipe method so $line isn't lost
|
||||||
echo "${line}. $i"
|
echo "${line}. $i"
|
||||||
done
|
done
|
||||||
printf '\033[0;32m>>>\033[0m '
|
printf '\033[0;32m>>>\033[0m '
|
||||||
|
IFS=''
|
||||||
read -r n
|
read -r n
|
||||||
|
|
||||||
if [ "$n" -le "$line" ];
|
if [ $n -le 5 ];
|
||||||
then
|
then
|
||||||
head -n "$n" /tmp/tmp3.txt | tail -n 1 > /tmp/tmp4.txt
|
head -n "$n" /tmp/tmp3.txt | tail -n 1 > /tmp/tmp4.txt
|
||||||
else
|
else
|
||||||
|
echo "$line $n"
|
||||||
echo "Input Error!"
|
echo "Input Error!"
|
||||||
line=0
|
line=0
|
||||||
select_option
|
select_option
|
||||||
|
@ -57,16 +67,7 @@ function select_option ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if type "wget" &> /dev/null
|
st-download "$name" "/tmp/${id}_url.txt"
|
||||||
then
|
|
||||||
wget -q "$name" -O "/tmp/${id}_url.txt"
|
|
||||||
elif type "curl" &> /dev/null
|
|
||||||
then
|
|
||||||
curl -s "$name" -o "/tmp/${id}_url.txt"
|
|
||||||
else
|
|
||||||
echo "Please install wget or curl."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cut and filter mp4 url
|
# Cut and filter mp4 url
|
||||||
|
|
||||||
|
@ -100,18 +101,10 @@ cat /tmp/tmp6.txt | sed -e 's/%25/%/g' -e 's/%25/%/g' -e 's/%3A/:/g' -e 's/%2F/\
|
||||||
|
|
||||||
if [ $stream_mode -eq 1 ]
|
if [ $stream_mode -eq 1 ]
|
||||||
then
|
then
|
||||||
st-video $(cat /tmp/tmp7.txt)
|
st-video "$(cat /tmp/tmp7.txt)"
|
||||||
else
|
else
|
||||||
if type "wget" &> /dev/null
|
st-download "$(cat /tmp/tmp7.txt)" "${id}_${quality_name}.${extension_name}"
|
||||||
then
|
|
||||||
wget --show-progress -qi /tmp/tmp7.txt -O "${id_name}_${quality_name}.${extension_name}"
|
|
||||||
elif type "curl" &> /dev/null
|
|
||||||
then
|
|
||||||
curl -# $(cat /tmp/tmp7.txt) -o "${id_name}_${quality_name}.${extension_name}"
|
|
||||||
else
|
|
||||||
echo "Please install wget or curl."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f /tmp/tmp[2-7].txt /tmp/${id}_url.txt /tmp/video_type_option.txt
|
|
||||||
|
rm -f /tmp/tmp[2-7].txt "/tmp/${id}_url.txt" /tmp/video_type_option.txt
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
# [ ] Search & Channel sort-by
|
# [ ] Search & Channel sort-by
|
||||||
# [X] Config video player, etc
|
# [X] Config video player, etc
|
||||||
# [ ] Overall better interface
|
# [ ] Overall better interface
|
||||||
# [ ] Cli args as commands
|
# [x] Cli args as commands
|
||||||
|
|
||||||
if [ -e $HOME/.config/shelltube ]
|
if [ -e "$HOME/.config/shelltube" ]
|
||||||
then
|
then
|
||||||
. $HOME/.config/shelltube
|
. "$HOME/.config/shelltube"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
|
|
Reference in New Issue