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: install:
mkdir -p $(PREFIX)/bin install -m 0755 shelltube lib/* $(PREFIX)/bin/
cp shelltube lib/* $(PREFIX)/bin/

View File

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

View File

@ -9,20 +9,20 @@
# dsfgbvesrht fd # dsfgbvesrht fd
##################### #####################
if type "vlc" &> /dev/null if [ -e $HOME/.config/shelltube ]
then then
vlc "${1}" . $HOME/.config/shelltube
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
fi fi
# Mi sxatas iom da komputoro if test -z $player_cmd
# ... sed, gxi estas tre bona kaj mojosas 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 # Usage: yt-channel.sh [-uci] userid||channel
if [ -e $HOME/.config/shelltube ]
then
. $HOME/.config/shelltube
else
results=21
fi
interactive_mode=0 interactive_mode=0
channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)" channel_file="/tmp/$(mktemp -u yt-channel_XXXXXX)"
@ -113,22 +119,33 @@ do
type="Playlist" type="Playlist"
title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//') title=$(echo "$LINE" | sed 's/.*title="//' | sed 's/".*//')
items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//') items=$(echo "$LINE" | sed 's/.*View full playlist (//' | sed 's/).*//')
printf '%s. %s\n' "$item_num" "$title" if [ $item_num -ge $((results+1)) ]
printf '%s | %s | %s\n' "$type" "$items" "$itemid" 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 else
type="Video" type="Video"
duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//') duration=$(echo "$LINE" | sed 's/.*Duration: //' | sed 's/\..*//')
itemid=$(echo "$LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//') itemid=$(echo "$LINE" | sed 's/.*href="\/watch?v=//' | sed 's/".*//')
title=$(echo "$LINE" | sed 's/.* title="//' | 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 then
printf '%s. ' "$item_num" printf '%s. ' "$item_num"
elif [ $item_num -lt 20 ]
then
printf '%s. ' "$item_num"
else else
break printf '%s. ' "$item_num"
fi fi
echo "$title" echo "$title"
printf ' ' printf ' '
@ -153,5 +170,6 @@ then
get_input get_input
fi fi
printf '\033[0m'
rm $temp_file 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 ] if [ $stream_mode -eq 1 ]
then then
if type "vlc" &> /dev/null st-video $(cat /tmp/tmp7.txt)
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
else else
if type "wget" &> /dev/null if type "wget" &> /dev/null
then then

View File

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

View File

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