migaku-official / Migaku-Dictionary-Addon

Migaku Dictionary allows users to lookup word definitions, export definitions to their cards in real-time, hear word audio and see word frequency, etc. If you have an issue please report it in the "Issues" tab. Reponses to issues can be slow on GitHub, for faster support consider joining our Discord server through our Patreon page.
GNU General Public License v3.0
64 stars 24 forks source link

Migaku throws error on KANJIDIC import #60

Open kanjieater opened 3 years ago

kanjieater commented 3 years ago

Type:

Environment:

I'm going to open a PR to resolve the issue:

Description: Migaku seems to not handle the KANJIDIC dictionaries that yomichan does. I wanted to generate keywords for a Kanji deck using Migaku. KANJIDIC in Json is available here: https://foosoft.net/projects/yomichan/

エラー 
エラーが発生しました。Shiftキーを押した状態でAnkiを起動してください。この操作により、インストールされているアドオン全てが一時的に無効になります。 
アドオン全てを無効にすると問題が起こらなくなる場合、メニューの[ツール]>[アドオン] でアドオン管理画面を開き、アドオンを1つまたはいくつか無効にしてAnkiを再起動してください。この手順を繰り返し、問題を引き起こすアドオンを特定してください。 
問題を引き起こすアドオンを特定できた際は、その問題をサポートサイトのアドオンセクションにご報告いただければ幸いです。 
Debug info:
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-01-30 16:06:11

Caught exception:
Traceback (most recent call last):
  File "aqt\progress.py", line 53, in handler
  File "aqt\main.py", line 142, in on_window_init
  File "aqt\main.py", line 190, in setupProfileAfterWebviewsLoaded
  File "aqt\main.py", line 231, in setupProfile
  File "<D:\Program Files\Anki2135\decorator.pyc:decorator-gen-54>", line 2, in loadProfile
  File "anki\hooks.py", line 638, in decorator_wrapper
  File "anki\hooks.py", line 633, in repl
  File "aqt\main.py", line 427, in loadProfile
  File "aqt\gui_hooks.py", line 2033, in __call__
  File "anki\hooks.py", line 583, in runHook
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 436, in checkForNewDictDir
    updateLs(dirLangs, dbLangs)
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 431, in updateLs
    updateDs(lang, getDirDicts(lang), mw.miDictDB.getDictsByLanguage(lang), frequencyDict)
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 91, in updateDs
    getDictFiles(lang, d, frequencyDict, True)
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 393, in getDictFiles
    loadDict(files, lang, dictName, frequencyDict, True, last = last)
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 188, in loadDict
    handleMiDictEntry(jsonDict, count, entry, freq)
  File "C:\Users\x\AppData\Roaming\Anki2\addons21\1655992655\main.py", line 223, in handleMiDictEntry
    reading = entry['pronunciation']
TypeError: list indices must be integers or slices, not str
KieranBrannigan commented 3 years ago

Hi,

Apologies but KANJIDIC isn't supported, we only support the yomichan dictionaries (yomichan has a couple different formats for kanji, terms, ...)

kanjieater commented 3 years ago

https://foosoft.net/projects/yomichan/ It's available on the yomichan site and is supported.

KieranBrannigan commented 3 years ago

Sorry my original comment wasn't very clear. The yomichan files have several different formats depending on the type of file. For example, the files under "Japanese Kanji", "Term and Kanji Frequencies", "Pitch Dictionary" have different formats to the files under "Japanese Vocabulary". The KANJIDIC file falls into one of the formats that isn't currently supported for installation.