summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsa Venton <asav1410@gmail.com>2020-10-18 17:06:20 +0100
committerAsa Venton <asav1410@gmail.com>2020-10-18 17:06:20 +0100
commit1114617d8c25085266471cd2f7f05282a2851e1b (patch)
treecc03a5bd1f39a6d53bd28b2ad738e31d5786e9ef
parent252fc55b1065e0cef8bad2c798c3c40adcc6c2ad (diff)
Remove quotes from output. Add audio file return option.
-rwxr-xr-xoeddefine.sh14
1 files 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