Basic config support

This commit is contained in:
Jaidyn Ann 2016-12-23 23:15:53 -06:00
parent 63de22e9c4
commit 2fa5a7d3b5
7 changed files with 81 additions and 54 deletions

View File

@ -1,3 +1,3 @@
PREFIX=/usr/local
install:
mkdir -p $(PREFIX)/bin
cp shelltube lib/* $(PREFIX)/bin/
install -m 0755 shelltube lib/* $(PREFIX)/bin/

View File

@ -10,14 +10,15 @@
# Cxu ne?
#####################
if type "wget" &> /dev/null
if test -z $download_cmd
then
wget -q "$1" -O "$2"
elif type "curl" &> /dev/null
then
curl -s "$1" -o "$2"
if type "wget" &> /dev/null
then
wget -q "$1" -O "$2"
elif type "curl" &> /dev/null
then
curl -s "$1" -o "$2"
fi
else
echo "Please install wget or curl."
sleep 2
exit 1
$download_cmd
fi

View File

@ -9,20 +9,20 @@
# dsfgbvesrht fd
#####################
if type "vlc" &> /dev/null
if [ -e $HOME/.config/shelltube ]
then
vlc "${1}"
elif type "mplayer" &> /dev/null
then
mplayer "${1}"
elif type "kaffeine" &> /dev/null
then
kaffeine "${2}"
else
sleep 2
echo "Please install either vlc, mplayer, or kaffeine."
exit 1
. $HOME/.config/shelltube
fi
# Mi sxatas iom da komputoro
# ... sed, gxi estas tre bona kaj mojosas
if test -z $player_cmd
then
if type "vlc" &> /dev/null
then
vlc "${1}"
elif type "mplayer" &> /dev/null
then
mplayer "${1}"
fi
else
$player_cmd "${1}"
fi

View File

@ -10,6 +10,12 @@
# Usage: yt-channel.sh [-uci] userid||channel
if [ -e $HOME/.config/shelltube ]
then
. $HOME/.config/shelltube
else
results=21
fi
interactive_mode=0
channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
@ -113,22 +119,33 @@ do
type="Playlist"
title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//')
items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//')
printf '%s. %s\n' "$item_num" "$title"
printf '%s | %s | %s\n' "$type" "$items" "$itemid"
if [ $item_num -ge $((results+1)) ]
then
break
elif [ $item_num -lt 10 ]
then
printf '%s. ' "$item_num"
else
printf '%s. ' "$item_num"
fi
printf '%s' "$title"
printf ' '
printf '%s | %s' "$type" "$items"
printf ' '
else
type="Video"
duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//')
itemid=$(echo "$LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//')
title=$(echo "$LINE" | sed 's/.* title="//' | sed 's/".*//')
if [ $item_num -lt 10 ]
if [ $item_num -ge $((results+1)) ]
then
break
elif [ $item_num -lt 10 ]
then
printf '%s. ' "$item_num"
elif [ $item_num -lt 20 ]
then
printf '%s. ' "$item_num"
else
break
printf '%s. ' "$item_num"
fi
echo "$title"
printf ' '
@ -153,5 +170,6 @@ then
get_input
fi
printf '\033[0m'
rm $temp_file

View File

@ -100,19 +100,7 @@ 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
if type "vlc" &> /dev/null
then
vlc $(cat /tmp/tmp7.txt)
elif type "mplayer" &> /dev/null
then
mplayer $(cat /tmp/tmp7.txt)
elif type "kaffeine" &> /dev/null
then
kaffeine $(cat /tmp/tmp7.txt)
else
echo "Please install either vlc, mplayer, or kaffeine."
exit 1
fi
st-video $(cat /tmp/tmp7.txt)
else
if type "wget" &> /dev/null
then

View File

@ -10,7 +10,13 @@
# Usage: yt-search.sh "$search_string"
# Bloody input...
if [ -e $HOME/.config/shelltube ]
then
. $HOME/.config/shelltube
else
results=21
fi
row=0
if [ "$1" == "-i" ]
@ -88,14 +94,21 @@ do
if echo "$LINE" | grep "View full playlist" > /dev/null
then
type="Playlist"
if [ $interactive_mode -eq 1 ]
then
printf '%s. ' "$item_num"
fi
title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//')
items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//')
if [ $item_num -ge $((results+1)) ]
then
break
elif [ $item_num -lt 10 ]
then
printf '%s. ' "$item_num"
else
printf '%s. ' "$item_num"
fi
printf '%s\n' "$title"
printf '%s | %s | %s\n' "$type" "$items" "$itemid"
printf ' '
printf '%s | %s\n' "$type" "$items"
printf ' '
else
type="Video"
duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//')
@ -110,7 +123,10 @@ do
author=$(echo "$LINE" | sed 's/.*\/user\///' | sed 's/".*//')
fi
if [ $item_num -lt 10 ]
if [ $item_num -ge $((results+1)) ]
then
break
elif [ $item_num -lt 10 ]
then
printf '%s. ' "$item_num"
else

View File

@ -2,7 +2,6 @@
####################
# Name: shelltube.sh
# Date: 2016-12-11
# Lisc: ISC
# Main: jadedctrl
# Desc: Full-shell YT client that avoids the YT API.
@ -17,10 +16,15 @@
# [ ] Channel & Playlist search
# [ ] Search filters
# [ ] Search & Channel sort-by
# [ ] Config video player, etc
# [X] Config video player, etc
# [ ] Overall better interface
# [ ] Cli args as commands
if [ -e $HOME/.config/shelltube ]
then
. $HOME/.config/shelltube
fi
search() {
output="$(mktemp -u /tmp/yt_XXXXXX)"
yt-search -i "$1" "$output"
@ -79,7 +83,7 @@ parse() {
search "$argument"
;;
/* )
search "${command#/}"
search "${command#/} $argument"
;;
channel )
channel "$argument"