From 1114617d8c25085266471cd2f7f05282a2851e1b Mon Sep 17 00:00:00 2001 From: Asa Venton Date: Sun, 18 Oct 2020 17:06:20 +0100 Subject: Remove quotes from output. Add audio file return option. --- oeddefine.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/oeddefine.sh b/oeddefine.sh index 1c3ae8a..0208723 100755 --- a/oeddefine.sh +++ b/oeddefine.sh @@ -58,7 +58,7 @@ _define() { # Return etymology if available _etym() { _getdata - output=$(echo "${result}" | jq '.results[].lexicalEntries[0].entries[0].etymologies[0]') + output=$(echo "${result}" | jq '.results[].lexicalEntries[0].entries[0].etymologies[0]' | tr -d \") if [ -z "$output" ]; then echo "No etymology found." else @@ -83,8 +83,16 @@ _thes() { exit 0 } +# Get URL for first audio file in returned data +_audio() { + _getdata + output=$(echo "${result}" | jq '.results[0].lexicalEntries[0].entries[0].pronunciations[0].audioFile' | tr -d \") + echo $output + exit 0 +} + _help() { - echo "Usage: !oeddefine [option] [word]. Options: -h help -t thesaurus -e etymology -d define -s source" + echo "Usage: !oeddefine [option] [word]. Options: -h help -t thesaurus -e etymology -d define -a audio -s source" exit 0 } @@ -97,6 +105,8 @@ elif [[ ${word} =~ "-t" ]]; then _thes elif [[ ${word} =~ "-et" ]]; then _etym +elif [[ ${word} =~ "-a" ]]; then + _audio else _define fi -- cgit v1.2.3