i can't work out how to download the sounds for JDIC (jim breen dictionary) http://www.csse.monash.edu.au/~jwb/cgi- … dic.cgi?1C
... anyone know how to do it?
... anyone know how to do it?
Edited: 2011-02-16, 9:15 am
http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=どくしょ&kanji=読書
bombpersons Wrote:Took a bit of figuring out in the source of the page but, you can do this:Nice find. This is going to be mad useful. Much easier than ripping the audio through Total Recorder.
To get the audio =) Quite cool, you can put just about any word in.Code:
http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=どくしょ&kanji=読書
import urllib, codecs
URL = u"http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=%(reading)s&kanji=%(kanji)s"
class Word:
def __init__(self, reading=u"", kanji=u""):
self.reading = reading
self.kanji = kanji
class Ripper:
def __init__(self):
self.words = []
def load(self, filename): # Load a list from file
file = codecs.open(filename, "rb", "utf-8")
for line in file:
word = line.split("\t")
self.words.append(Word(word[0], word[1]))
print("Loaded list at: ", filename)
def download(self):
for word in self.words:
# Try and download this word
webFile = urllib.urlopen((URL % {u'reading': word.reading, u'kanji': word.kanji}).encode("utf-8"))
file = open(word.kanji + u".mpga", "wb")
file.write(webFile.read())
file.close()
webFile.close()
print "Downloaded " + word.kanji
if __name__ == "__main__":
ripper = Ripper()
ripper.load("words.txt")
ripper.download()#!/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
donenest0r Wrote:Maybe the following: format a list of words into two columns (?), then script runs and attaches link template around the first and second column, and then a download manager can add them as a batch or something? Or is that actually what the above posts already do, hehe.Yes, my script is using wget to download and save the audio files to current directory.
Pauline Wrote:UsageDoes your script with work Cygwin, do you know? If so, that'd be quite handy.
1) Create a file with two columns: kana kanji (use space or tab between them)
2) Run ./script.sh < file.txt
3) Check log.txt for failed downloads
brandon7s Wrote:Not completely, I think. Seems like md5sum is not included by default in Cygwin, but that only affects the detection of missing audio (uses hashes to identify them). The important program is wget.Pauline Wrote:UsageDoes your script with work Cygwin, do you know? If so, that'd be quite handy.
1) Create a file with two columns: kana kanji (use space or tab between them)
2) Run ./script.sh < file.txt
3) Check log.txt for failed downloads
#!/bin/bash
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"
doneIceCream Wrote:if there's anyone out there that can turn this into a really simple program, i will love you foreverSecond that! This thread is incomprehensible to a person like me...
mezbup Wrote:Would really love this if it were an Anki plugin that could show up whilst making a card. Say you have a word 遺体 in the question field and could click a button to download and add the sound file would be so awesome.I second that!
mygbmygb Wrote:This would be awesome. Might try to do something like this myself if I find the time.mezbup Wrote:Would really love this if it were an Anki plugin that could show up whilst making a card. Say you have a word 遺体 in the question field and could click a button to download and add the sound file would be so awesome.I second that!
Psycho_Dad Wrote:If anyone using Firefox with it's awesome smart keyword search function (if not, take a look here) then there is a solution to download audio clips from WWWJDIC from your browser's addressbar with the help of the link provided by sugarlevi in one of the previous comments.Thanks for this tip! I only tried this today, and it went swimmingly. Not something I'd want to do in bulk, but it worked for individual cards I was too lazy to add audio to whilst making them the first time.
If you check out this link there is a looong javascript code. Change the '###INSERT YOUR KEYWORD SEARCH URL HERE###' to 'http://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=%s&kanji=%s' and copy the whole thing onto your clipboard. Create a new bookmark which name could be anything. The location should be the loooong javascript thingy (which you've edited). The keyword also could be anything, but make it descriptive and short (I use 'ja' for the keyword), then save it.
After this you can download an audio file from JapanesePod101 by writing "yourkeyword reading expression" to your location/address/search/whateverbar:
e.g. "keyword がくせいせいかつ 学生生活"
After this something should popup in FF, like windows media player, or some other software which is associated with the filetype in firefox (not in your OS). For me, media player classic pops up, plays the audio (if it's available) and I can save the mp3 as I wish.
I hope this idea will come in handy for someone.
ruiner Wrote:This is awesome! Thanks. All hail mistamark!!! ;pGlad that worked for you! Yeah, about the smoke, it happens on mine too!
It worked great, except I had to hit 'continue' after some kind of index out of bounds error. Doesn't seem to actually hurt anything. Pretty sure my computer always smokes like that.