Update Note attributes and fetch pinyin from MDBG#3
Conversation
The Note class no longer has a '_model' attribute. The 'note_type()' method achieves the same functionality and allows the addon to remain compatible with the current version of Anki.
Wikimedia has restricted the access for web crawlers to fetch data from their resources. MDBG remains as a free alternative for fetching pinyin for Chinese characters.
|
@SamtoonChateaPro Thanks for putting in this PR--I've had ±0 time to work on this over the last few years 😂 It's been a really long time since I've used Anki, so I'll ask you: in your testing, does this sort #2? |
Hey! Thanks for the quick reply and thanks for ever coming up with this awesome idea of a project! And yeah, when I discovered this addon last night and found out that your last reply was years ago but you still were active with other projects, I supposed you must've been busy with other projects. I even didn't have much hope for you to even check the PR, but the fact that you did and this fast really means a lot. |
|
Looks good! Okay, feel free to merge it in whenever it's in a ready state (unless I have to pull the trigger, in which case just let me know) |
Yeah that can go for now. I wrote all this as a first foray into Python myself, and I'm not convinced my regex proficiency was that good either :-D Regarding the MDBG issue--you're right, that gets difficult. I wonder how you'd feel about implementing some way to choose? |
Well, the only way I can think of would require some sort of interface or window. That would take me quite some time tho, as I would need to have a better understanding of Anki's code and events to implement it. For the time being, in order to revive this addon ASAP, what about adding a new configurable field to allow the user to choose if they wish to fetch the metadata from the hanzi, from the pinyin or from both? We could then add a warning on the Addons page indicating that in case MDBG got multiple results from the hanzi or the pinyin input, it will fill the fields with the metadata from the first result. |
|
Okay just getting back to this—I had a lot more time for this over Christmas :-D Honestly putting in some kind of configuration variable would probably fine; no need to put in a full-blown UI to choose (also I'm not sure Anki even lets you spawn a custom UI). And in interest of simplicity, it'd probably be fine to just set a default and then add configuration instructions to the readme if you'd like 🤷♂️ |


*Replace obsolete Note attributes to maintain compatibility with the current version of Anki.
*Switch from using Wiktionary to MDBG for fetching pinyin due to access restrictions on Wikimedia resources.