commit 7e96d80dac269fef9e53dc76e56f588fb1d771a5
parent 4ed7eddeb24b431b1fe28e288013d4998aba8445
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 15 Jan 2020 11:39:46 +0100
Improve help text
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/.local/bin/lyrics b/.local/bin/lyrics
@@ -1,16 +1,20 @@
#!/bin/sh
+# requirements: hurl or curl, w3m
version=0.1.0
show_help()
{
- echo "usage: ${0##*/} [OPTIONS] [artist - song]"
- echo "fetches lyrics from lyricwiki."
+ echo "usage: ${0##*/} [OPTIONS] [ARTIST - SONG]"
+ echo "fetches lyrics from lyricwiki. The song is identified by artist name"
+ echo "and song title in the format 'ARTIST - SONG'. If these are not"
+ echo "passed as an argument or read from mpd (option -m), they are"
+ echo "expected as stdin."
echo
echo "OPTIONS are one or more of the following:"
echo " -h, --help show this message"
echo " -v, --version show version and license information"
- echo " -V, --verbose show version and license information"
+ echo " -V, --verbose show verbose information during execution"
echo " -m, --mpd fetch lyrics for song currently playing on mpd"
echo " -- do not consider any following args as options"
}
@@ -18,7 +22,7 @@ show_help()
show_version()
{
echo "${0##*/} version $version"
- echo "Licensed under the ISC License"
+ echo "licensed under the ISC License"
echo "written by Anders Damsgaard, anders@adamsgaard.dk"
echo "https://src.adamsgaard.dk/dotfiles"
}
@@ -40,9 +44,10 @@ string_to_artist_and_song()
fetch_lyrics_lyricwiki()
{
- local _a="$(echo "$1" | sed 's/ /_/g')"
- local _s="$(echo "$2" | sed 's/ /_/g')"
- local _qanswer="$($fetcher "https://lyrics.fandom.com/api.php?fmt=json&func=getSong&artist=${_a}&song=${_s}")"
+ local _a, _s, _qanswer
+ _a="$(echo "$1" | sed 's/ /_/g')"
+ _s="$(echo "$2" | sed 's/ /_/g')"
+ _qanswer="$($fetcher "https://lyrics.fandom.com/api.php?fmt=json&func=getSong&artist=${_a}&song=${_s}")"
if echo "$_qanswer" | grep -q "'lyrics':'Not found'"; then
die 'no lyrics found'
fi