tmilovanov / wisecreator

Utility for adding word wise information to non amazon books
319 stars 53 forks source link

Wordwise Generation for Kindle android app #11

Open Tikotik opened 6 years ago

Tikotik commented 6 years ago

Is there a way to add the generated wordwise kll file for android kindle app? I observed that wordwise information for the app is stored at /data/data/com.amazon.kindle/databases/wordwise/wordwise.kll.en.en.db as a single file for all downloaded books, And Wordwise.override.[asin].en.db - maybe for matching above file to each book

Can you look into it in future for matching sideloaded books with wordwise.kll file? Thanks.

Ephemerality commented 6 years ago

It appears that the Kindle app looks in /data/user/0/com.amazon.kindle/databases for a file named WordWise.en.[ASIN].[database_name].db (where the database name usually starts with CR_ for Amazon books). You can get the dbname with the mobitool included, just run mobitool-win32.exe -i on your book and it's the first field in the Palm doc header:

Full name: Fleet of Worlds

Palm doc header:
name: CR!25XE4QN50Q2TQDG810J31GQY6Y9D

So for this book I had to use WordWise.en.B000UZPHTE.CR_25XE4QN50Q2TQDG810J31GQY6Y9D.db

You need root to access the /data/user folder (which you have but many don't).
You will also have to change permissions/security context on any files you move to that folder, from a terminal emulator app or via adb shell

su
cd /data/user/0/com.amazon.kindle/databases
ls -Z  (to get proper group & security context)
chown u0_a93:u0_a93 filename (where u0_a93 is the group from your ls -Z)
chcon u:object_r:app_data_file:s0:c512,c768 filename
(again, take the context from your ls -Z, maybe it's the same for everyone?)

The override file is different and seems to just provide a mapping for original/corrected terms.

Tikotik commented 6 years ago

No luck. What I did:

  1. grabbed this test book
  2. Ran the wisecreator, now I have a modified mobi (472KB from 517KB) and the file: LanguageLayer.en.4312fce0-d09d-4ab3-bbc1-3407e6ff3f08.kll
  3. Renamed the above file to WordWise.en.4312fce0-d09d-4ab3-bbc1-3407e6ff3f08.Ender_8217_s_Game.db based on your suggestion. I hope nothing wrong with directly changing .kll to .db
  4. Pushed the above db to /data/user/0/com.amazon.kindle/databases and changed permissions. (although I am not getting any group info from ls -Z, I ran both chown and chcon)
  5. Finally pushed the .mobi file to Android/data/com.amazon.kindle/files
  6. Still kindle doesn't recognise its wordwise.
Ephemerality commented 6 years ago

Did you do the permissions stuff too (from a terminal emulator on the phone or through adb)? Edit: Sorry, missed the part where you said you did. Can you paste the line from ls -Z of your file? Edit 2: Looks like I was wrong about the dbname portion, it's actually the GUID, BUT it also looks for one in the format WordWise.en.ASIN.db! (still within the /data/user/0/com.amazon.kindle/databases` folder though). I started fresh with a different book and was able to get it working there as well, but the locations of the highlights were off for some reason.

Tikotik commented 6 years ago

Great. Working after renaming it. Although I am not suffering with location offset for this one file, I will update after multiple tries. So, after permission changes from terminal emulator and renaming, output of ls -Z for my file is: u:object_r:app_data_file:s0:c512,c768 WordWise.en.4312fce0-d09d-4ab3-bbc1-3407e6ff3f08.db

Ephemerality commented 6 years ago

Nice. Good to know the security context is the same for yours too.