Hello back folks. Wishing everyone a happy evening/morning.
I am in process of making OALD + Collocation (maybe a thesaurus in future as well)
I have worked on OALD10 thus far. Have purchased a license fo collocation dictionray from official. I wll then add to this dictionray as well.
Right now i am stuck with js file. I plays the US pronunciation. But no audio on UK. I have js/css files along with trial dictionay. I am providing my packer python script. Someone here articualte in programming can have a look and see what is causing the issue. I will upload the content in short time. Kindly help me sort out this issue so that the whole community can be benefited from this product.
Anyone will to help reach me in PM/DM so i can provide the project files to sort this issue. TY
link update to v2:
6 个赞
So the dictionray cannot play UK/GB/BrE sound
but plays US/NAmE
with provided js/css
Link update to v2.
provided collocation dictionary inclusion.
Collocation enteries go with suffix _cl
Can be opened directly form collocation box under OADL10 enteries
link v3
HTML with working CSS/JS:
Here i have packed my html with js and css packed with html files.
The css/js works fine when placed next to the html files. It perfectly plays audio and does other function. However when i packed it with this python packer it somehow breaks the audio pronunciation.
The Version 2 link use a different js which strangely works only on US audio. No BrE/UK/GB audio is played.
I will continue finishing the scrapping and then publish the dictionary anyway with limited functionality. Until someone comes to the rescue. 
1 个赞
I debugged your OALD10.js script and found that the buildCdnUrl function doesn’t work properly. When the function works with ‘audio/gb/zumba_1_gb_1.mp3’, it returns a wrong url:
‘https://www.oxfordlearnersdictionaries.com/media/english/gb_pron/z/zum/zumba/zumba_1_gb_2.mp3’
The right url must be:
‘https://www.oxfordlearnersdictionaries.com/media/english/uk_pron/z/zum/zumba/zumba_1_gb_2.mp3’
Plus, there are typos or errors with some of the html pages from the dictionary website. You’d better remove these typos/errors and downsize the package by sanitizing all pages with BeautifulSoup.
2 个赞
You can replace the line
var pron = m[1] + ‘_pron’; // “gb” → “gb_pron”
with
var pron=m[1]==‘us’?‘us_pron’:‘uk_pron’;
1 个赞
fix_all_audio.py (3.4 KB)
最关键的是html中音源url的处理:
从
<div class="sound audio_play_button pron-uk icon-audio" data-audio-src="audio/gb/zodiac__gb_1.mp3" data-sound="sound://audio/gb/zodiac__gb_1.mp3" title="zodiac pronunciation English">
替换为
<a class="sound audio_play_button pron-uk icon-audio" href="sound://audio/gb/zodiac__gb_1.mp3" title="zodiac pronunciation English"></a>
然后用楼主的python脚本转换为mdx和mdd。
经测试,不用js脚本,在windows平台三个词典软件下都能正常播放。
GoldenDict-ng 26.4.0
Eudic欧路词典26.2.0
MDictPC-2.0.12
下一贴附测试结果。
1 个赞
同样一套mdx mdd,三个词典软件对音源url 正反斜杠 的处理(测试时只加载一部词典、不加载任何js):
sound://协议,a链接,反斜杠:
<a class="sound audio_play_button pron-us icon-audio" href="sound://\audio\us\zoo__us_1.mp3" title="zoo pronunciation American"></a>
转换为mdd测试:
GoldenDict-ng 26.4.0如下(可以播放)
<a class="sound audio_play_button pron-us icon-audio" href="gdau://14d9781360c308797f91e4274af2adc6/\audio\us\zoo__us_1.mp3" onclick="return false;" title="zoo pronunciation American"></a>
Eudic欧路词典26.2.0如下(可以播放)
<a class="sound audio_play_button pron-us icon-audio" href="sound://\audio\us\zoo__us_1.mp3" title="zoo pronunciation American"></a>
MDictPC-2.0.12 中如下(不能播放)
<a class="sound audio_play_button pron-us icon-audio" href="mdx://mdict.cn/sound/20859770/\audio\us\zoo__us_1.mp3" title="zoo pronunciation American"></a>
sound://协议,a链接,修改为正斜杠后(sound://audio、sound:///):
<a class="sound audio_play_button pron-uk icon-audio" href="sound://audio/gb/zoo__gb_1.mp3" title="zoo pronunciation English"></a>
<a class="sound audio_play_button pron-us icon-audio" href="sound:///audio/us/zoo__us_1.mp3" title="zoo pronunciation American"></a>
再转换为mdd测试:
MDictPC-2.0.12 中变为如下(可以播放)
<a class="sound audio_play_button pron-uk icon-audio" href="mdx://mdict.cn/sound/20859770/audio/gb/zoo__gb_1.mp3" title="zoo pronunciation English"></a>
<a class="sound audio_play_button pron-us icon-audio" href="mdx://mdict.cn/sound/20859770//audio/us/zoo__us_1.mp3" title="zoo pronunciation American"></a>
GoldenDict-ng 26.4.0如下(可以播放)
<a class="sound audio_play_button pron-uk icon-audio" href="gdau://14d9781360c308797f91e4274af2adc6/audio/gb/zoo__gb_1.mp3" onclick="return false;" title="zoo pronunciation English"></a>
<a class="sound audio_play_button pron-us icon-audio" href="gdau://14d9781360c308797f91e4274af2adc6//audio/us/zoo__us_1.mp3" onclick="return false;" title="zoo pronunciation American"></a>
Eudic欧路词典26.2.0如下(可以播放)
<a class="sound audio_play_button pron-uk icon-audio" href="sound://audio/gb/zoo__gb_1.mp3" title="zoo pronunciation English"></a>
<a class="sound audio_play_button pron-us icon-audio" href="sound:///audio/us/zoo__us_1.mp3" title="zoo pronunciation American"></a>
兼容性:
三个词典均支持 href="sound://
mdict不支持反斜杠
GoldenDict-ng和欧路词典对正反斜杠不挑剔;
GoldenDict-ng会将 sound:// 转换为 gdau://
欧路词典对 sound:// 原封不动
1 个赞
如果把音频文件放在mdd中,就需要做出这样的修改。
1 个赞
Thanks a bunch my freind. It now works. Gratitude from the bottom of my heart 
1 个赞
I intend no delay. As soon as the work is finished, i am publishing this right away. 
This error was holding me at the bay. Now i have resumed working. I will def sanitize all pages to make it free from all the external/unwanted links 