aboutsummaryrefslogtreecommitdiff
path: root/bulk-audio/get
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-04-25 09:55:40 +0200
committerlonkaars <loek@pipeframe.xyz>2024-04-25 09:55:40 +0200
commitb334235d3488fa3ee9023a6fb66fbca7db259dc6 (patch)
tree5336e0922b4685c8fc62ed38879ca8b0f9f07e78 /bulk-audio/get
parenta29b452b89b2f83f0785f7e05ef5de0e60645b5a (diff)
add local-audio-yomichan source
Diffstat (limited to 'bulk-audio/get')
-rwxr-xr-xbulk-audio/get14
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