Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
49 stars 6 forks source link

Unable to transfere my note to anki #4

Closed YashaNoos closed 1 year ago

YashaNoos commented 1 year ago

First of all, thanks for your work. I have been using Koreader for a year now and was really hoping for an anki integration. Sadly I can't get this plugin to work with both my kobo Clara 2e and my boox nova air. I have installed the plugin via USB on both my device and changed the ankiconnect config =>

{
    
    "apiKey": null,

    "apiLogPath": null,

    "ignoreOriginList": [],

    "webBindAddress": "0.0.0.0",

    "webBindPort": 8765,

    "webCorsOriginList": [

        "http://localhost"
   
     ]

}

wifi on my devices is on (SSH works on my pc without trouble)

But every time I try to synchronize my note I get this error.

Screenshot_20230521-095734 1

Maybe I'm missing something obvious, I'm a complete noob when it come to tech especially network stuff. Anyway thanks for your time and your work on this project.

nairyosangha commented 1 year ago

Considering it did not return a timeout error, my guess would be that you configured the IP/port correctly on the ereader, but your firewall on the PC where anki is running is blocking connections on port 8765.

YashaNoos commented 1 year ago

Thanks for your answer! I have tried to add exceptions in my firewall and even deactivate them (winDefender and bitdefender) entirely but it still doesn't work. I don't know if it's relevant or not but the "connection refused" message is on my boox nova air, my kobo clara 2e give me a "timeout" instead. I have also tried to use one of my device IP directly for the webBindAddress and Anki gave me this message upon restart:

anki_oiSkcRB91f

I have spent a couple hours on this and I think I have reached my competency limit which, was pretty low to begin with. So maybe has an alternative, I would like to know if there's a way to import the JSON created by the plugin into Anki PC, I was able to locate and download it but I don't know if there is a way for Anki to add notes from it. Thanks for your time

nairyosangha commented 1 year ago

I don't know if it's relevant or not but the "connection refused" message is on my boox nova air, my kobo clara 2e give me a "timeout" instead.

That seems strange, I would expect a timeout when you put in the wrong IP, and connection refused when the port was wrong.

I have also tried to use one of my device IP directly for the webBindAddress and Anki gave me this message upon restart:

Don't do that, webBindAddress in the ankiconnect settings should be 0.0.0.0

There was 1 issue before from another windows user here who figured it out in the end, take a look at that. I'd also recommend using the built-in terminal ( see my comment on that link ) to see if it works, easier to test.

I would like to know if there's a way to import the JSON created by the plugin into Anki PC, I was able to locate and download it but I don't know if there is a way for Anki to add notes from it.

It's technically possible, but you'd need to make a script to do it. The json file created by the plugin contains a list of of requests you'd have to send to anki-connect one by one. There's example code on how to do that in the anki-connect documentation

YashaNoos commented 1 year ago

There was 1 issue before from another windows user here who figured it out in the end, take a look at that. I'd also recommend using the built-in terminal ( see my comment on that link ) to see if it works, easier to test.

EUREKA! haha I didn't got that I needed to change the AnkiConnect URL setting in koreader from: "http://localhost:8765/" to my Ipv4 -_- Now it works perfectly on both my devices, except for the forvo audio being downloaded automatically into it's dedicated field. But that's not a big deal I have an addon to help me do it manually. Thanks again for your time and patience, you created an awesome tool!

PS: I see that the looked up word in context_field is automatically tagged with "<b></b>" is there a way to add other tags like color?

nairyosangha commented 1 year ago

Glad you got it working in the end :)

Now it works perfectly on both my devices, except for the forvo audio being downloaded automatically into it's dedicated field. But that's not a big deal I have an addon to help me do it manually.

I realized that I've hardcoded 'ja' (Japanese) as language for the forvo lookups, so if you try it on English words (like in your example earlier) it's probably not going to work, I'll make it look at the book's or dictionary's language instead.

PS: I see that the looked up word in context_field is automatically tagged with "" is there a way to add other tags like color?

No, but you can add color by styling the b tag on your card's CSS right? I'd like to leave markup to Anki where possible

YashaNoos commented 1 year ago

I realized that I've hardcoded 'ja' (Japanese) as language for the forvo lookups, so if you try it on English words (like in your example earlier) it's probably not going to work, I'll make it look at the book's or dictionary's language instead.

Yes I was adding English words, I should have realized that forvo wasn't gonna magically guessing in which language I was requesting pronunciation sample...

No, but you can add color by styling the b tag on your card's CSS right? I'd like to leave markup to Anki where possible

Again haven't thought about that :p After searching a little bit online I have come up with that if anyone's interested : first define a class in the template then just add that in styling

.mysentence b {
 
  color: blue;

}

Thanks for your quick answer and have a nice day!

nairyosangha commented 1 year ago

Yes I was adding English words, I should have realized that forvo wasn't gonna magically guessing in which language I was requesting pronunciation sample...

FYI, this should work now. The plugin will look at your dictionary's language, or the book's as fallback, to determine the language ( https://github.com/Ajatt-Tools/anki.koplugin/commit/da594d567f555b5b356dcb95153b9471722a1ea4 )