Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes Info API isn't implemented causing MalformedJsonException when updating card image through mokuro files #50

Open
precondition opened this issue Jan 1, 2024 · 3 comments

Comments

@precondition
Copy link

precondition commented Jan 1, 2024

When using the HTML files provided by Mokuro (not to be confused with the separate Mokuro Reader app) and enabling Anki integration in the advanced settings, I can successfully create new cards by pressing the green button in the Yomibaba/Yomitan pop-up but I can't add a picture to the card.

Screenshot of the advanced settings

image

Looking at the dev console of the Kiwi Browser mobile app that I use, I can see the following stack trace when I press "Complete":

Uncaught (in promise)
com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $
    at
com.google.gson.JsonParser.parseReader(JsonParser.java:66)
    at
com.google.gson.JsonParser.parseString(JsonParser.java:47)
    at
com.kamwithk.ankiconnectandroid.routing.AnkiAPIRouting.findRouteHandleError(AnkiAPIRouting.java:101)
    at
com.kamwithk.ankiconnectandroid.routing.APIHandler.chooseAPI(APIHandler.java:33)
    at
com.kamwithk.ankiconnectandroid.routing.RouteHandler.get(RouteHandler.java:70)
    at
fi.iki.elonen.router.RouterNanoHTTPD$DefaultStreamHandler.post(RouterNanoHTTPD.java:100)
    at
fi.iki.elonen.router.RouterNanoHTTPD$UriResource.process(RouterNanoHTTPD.java:386)
    at
fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
    at
fi.iki.elonen.router.RouterNanoHTTPD$UriRouter.process(RouterNanoHTTPD.java:596)
    at
[...]

    at java.lang.Thread.run(Thread.java:764)
Caused by:
com.google.gson.stream.MalfromedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 14 path $
    at
com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1597)
    at
com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1404)
    at
com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
    at
[...]

(I didn't find a way to copy the contents of the error from the Kiwi browser console so this was transcribed by hand on the basis of the screenshots in the spoiler)

Screenshots of error

image
image

I made sure to open AnkiDroid, start the Ankiconnect (v1.12) service and added https://mokuro.moe to the CORS host in the settings. I also disabled battery optimizations on the Ankiconnect app and the Kiwi Browser app.

I tested doing the exact same steps on desktop (open the same web page, highlight the same word, create the card, add an image via mokuro) and it worked fine so it is not as if the mokuro file is serving bad JSON data that Ankiconnect can't do anything about, since it seems like the desktop version of Ankiconnect has no issue with the commands received from mokuro.

@Twinov
Copy link
Contributor

Twinov commented Jan 1, 2024

You should go to the Network tab in the browser dev tools and click on the request, then look at the json and make sure it's correctly formatted or post it here.

@precondition
Copy link
Author

precondition commented Jan 1, 2024

I'm seeing this payload in the POST request:

{
action: "notesInfo", 
version: 6, 
params: {
notes: [<ID obtained from response of previous `findNotes` query>]}
}

Judging from the existence of #46, I'm guessing that Ankiconnect does not support the notesInfo action and this might be the source of my issue?

@Twinov
Copy link
Contributor

Twinov commented Jan 1, 2024

Yeah that's correct, notesInfo isn't implemented yet.

@KamWithK KamWithK changed the title MalformedJsonException when updating card image through mokuro files Notes Info API isn't implemented causing MalformedJsonException when updating card image through mokuro files Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants