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)
|
a)
|
||||||
artist="true"
|
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)
|
s)
|
||||||
song="true"
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -191,13 +193,21 @@ elif [[ $# == "1" ]]; then
|
||||||
fi
|
fi
|
||||||
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
|
||||||
song=$(echo "$@" | grep -Eo "\-s [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-s//g | sed s/-//g | sed s/^" "//g)
|
echo "Error: the -a and the -s flag must be used to fetch lyrics."
|
||||||
if [[ $song == "" ]];then { echo "Error: song could not be parsed from input."; exit 1; };fi
|
exit 1
|
||||||
artist=$(echo "$@" | grep -Eo "\-a [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-a//g | sed s/-//g | sed s/^" "//g)
|
elif $artist && $song;then
|
||||||
if [[ $artist == "" ]];then { echo "Error: artist could not be parsed from input."; exit 1; };fi
|
song=$(echo "$@" | grep -Eo "\-s [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-s//g | sed s/-//g | sed s/^" "//g)
|
||||||
getConfiguredClient || exit 1
|
if [[ $song == "" ]];then { echo "Error: song could not be parsed from input."; exit 1; };fi
|
||||||
if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1;fi
|
artist=$(echo "$@" | grep -Eo "\-a [ a-z A-Z 0-9 . \ ]*[ -]?" | sed s/-a//g | sed s/-//g | sed s/^" "//g)
|
||||||
checkInternet || exit 1
|
if [[ $artist == "" ]];then { echo "Error: artist could not be parsed from input."; exit 1; };fi
|
||||||
getLyrics "$artist" "$song" || exit 1
|
getConfiguredClient || exit 1
|
||||||
printLyrics
|
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