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