Back

JDIC sound files

#9
Here is a shell script (UNIX only?) for batch downloading. If a clip for an entry does not exist, it is logged in log.txt:

Code:
#!/bin/bash

missing=7e2c2f954ef6051373ba916f000168dc # Hash of "no clip exist" message

if [ $# -ne 0 ]
then
  echo "Usage: `basename $0` < input "
  echo "input: Field 1: かな, Field 2: 漢字"
  exit 65 # Bad arguments
fi

while read kana kanji
do
  wget -q "http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=$kana&kanji=$kanji" \
         -O "$kana-$kanji.mp3"

  clip_hash=`md5sum $kana-$kanji.mp3 | cut -d ' ' -f1 `

  if [ "$clip_hash" = "$missing" ]
  then
    echo "Clip for $kana $kanji did not exist" >> log.txt
    rm $kana-$kanji.mp3
  fi
done
Edit: Fixed a mistake with the logging.
Edit2: Fixed bug with renaming of audio file
Edited: 2009-12-11, 8:45 am
Reply

Messages In This Thread