mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
General fixes for lyrics
This commit is contained in:
parent
3cc7264593
commit
5c12ac0bd3
1 changed files with 21 additions and 11 deletions
|
@ -165,11 +165,13 @@ while getopts "f:a:s:uvh" opt; do
|
|||
;;
|
||||
a)
|
||||
artist="true"
|
||||
if [[ "$(echo "$@" | grep -Eo "\-s")" == "-s" ]];then song="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)
|
||||
;;
|
||||
s)
|
||||
song="true"
|
||||
if [[ "$(echo "$@" | grep -Eo "\-a")" == "-a" ]];then artist="true";fi # wont go through both options if arg spaced and not quoted this solves that issue (dont need this but once had bug on system where it was necessary)
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2file="false"
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -191,7 +193,10 @@ elif [[ $# == "1" ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if ! $artist || ! $song;then { echo "Error: the -a and the -s flag must be used to fetch lyrics."; exit 1; }; fi
|
||||
if ($artist && ! $song) || ($song && ! $artist);then
|
||||
echo "Error: the -a and the -s flag must be used to fetch lyrics."
|
||||
exit 1
|
||||
elif $artist && $song;then
|
||||
song=$(echo "$@" | grep -Eo "\-s [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-s//g | sed s/-//g | sed s/^" "//g)
|
||||
if [[ $song == "" ]];then { echo "Error: song could not be parsed from input."; exit 1; };fi
|
||||
artist=$(echo "$@" | grep -Eo "\-a [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-a//g | sed s/-//g | sed s/^" "//g)
|
||||
|
@ -201,3 +206,8 @@ if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1;fi
|
|||
checkInternet || exit 1
|
||||
getLyrics "$artist" "$song" || exit 1
|
||||
printLyrics
|
||||
else
|
||||
{ clear; echo "You shouldnt be here but maaaaaaybeee you slipped passed me, learn to use the tool!"; sleep 5; clear;}
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue