diff options
-rwxr-xr-x | bulk-audio/get | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/bulk-audio/get b/bulk-audio/get index dae1943..6243797 100755 --- a/bulk-audio/get +++ b/bulk-audio/get @@ -1,7 +1,7 @@ #!/bin/sh SCRIPT_NAME="$0" -SOURCES="lp101,lp101_alt,jisho,nhk" +SOURCES="local_audio,lp101,lp101_alt,jisho,nhk" KANJI="" KANA="" @@ -9,6 +9,16 @@ urlencode() { printf '%s' "$1" | od -An -tx1 | tr ' ' '%' | tr '[:lower:]' '[:upper:]' } +local_audio() { + URL="http://localhost:5050/" + res="$(curl -sLGo - "$URL" --data-urlencode "term=$KANJI" --data-urlencode "reading=$KANA")" + [ $? -ne 0 ] && return + URL="$(echo "$res" | jq --raw-output '.audioSources[0].url // empty')" + [ -z "$URL" ] && return + curl -sLo - "$URL" + exit 0 +} + lp101() { URL="https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=$KANJI&kana=$KANA" # 52288 is the content-length of the "the audio for this clip is currently @@ -17,7 +27,6 @@ lp101() { curl -X HEAD -iso - "$URL" | awk '/^Content-length:/ { exit $2 == 52288 }' [ $? -ne 0 ] && return curl -sLo - "$URL" - exit 0 } lp101_alt() { @@ -65,6 +74,7 @@ options: -h show help sources: + local TheMoeWay local-audio-yomichan server lp101 JapanesePod101 lp101_alt JapanesePod101 (Alternate) jisho Jisho.org |