Mobileread
[Kindle Touch] Calibre Kindle Collections Plug-in Hooks
#1  sumpin 03-04-2012, 11:43 PM
image » image »
This extension converts the collections in the Content Catalog (/var/local/cc.db) on the Kindle Touch to a JSON file (/mnt/us/system/collections.json) that can be read and updated by the Calibre Kindle Collections Plug-in. It then inserts/updates the collections managed by Calibre in Content Catalog. The script is compatible with collections and content that only exist on the Kindle and not in Calibre per the plug-in and books may exist in multiple collections.

Requirements:
1. Jailbreak - http://www.mobileread.com/forums/sho...d.php?t=160454
2. Launcher - http://www.mobileread.com/forums/sho...d.php?t=161263
3. Calibre - http://calibre-ebook.com/download
4. Calibre managed data stored on the Kindle in documents/calibre (i.e., under Calibre Preferences > Sending books to devices, Save template starts with: calibre)
5. Sqlite3 built with loadable extension support to run on the Kindle (included)

Install:
1. Extract both tar files to /mnt/us/extensions (If your zip file extractor has a setting like "TAR file smart CR/LF conversion", make sure it is disabled or the scripts cannot run)
2. Restart Kindle

To Use:
1. Select “Create input for Calibre” to export the existing collections
2. Connect Kindle to computer, run Calibre Kindle Collections Plug-in, eject Kindle
3. Select “Import data from Calibre and reboot” to import the new/modified collections

Note:
By default, when the Calibre data is loaded, the access times of all books is updated (avoid by changing –uat to +uat in menu.json) and the database is cleaned up by deleting the Collections Journal and by issuing an SQL VACUUM command (avoid by changing –vacuum to +vacuum in menu.json). To disable removing collections with no entries on import, add +rec to the command line of json2db.sh in menu.json.

By default, 5 copies of cc.db are maintained in /mnt/us/system. This can be changed by modifying the command line params of the json2db.sh script in menu.json.

If you run the import procedure too soon after loading data via Calibre, you may find that some books that are in a collection show up as not in a collection. Simply run the import again.

This supersedes my input to http://www.mobileread.com/forums/sho...d.php?t=160855 as that thread has taken the directory structure driven approach of CollectionSync http://www.mobileread.com/forums/sho...1&postcount=16.

I've split the release up into two parts. One tar file contains the sqlite3 binary and loadable extension needed and the other contains the Launcher hooks and scripts that do all the work.

I added a "progress bar" to the non-verbose import/export screens to give feedback that it's ticking along when importing large databases and I added verbose import/export to the menu to aid in trouble shooting and boredom reduction.

Updated for firmware 5.1.0 (use dynamic launcher menu, eips command line changes). Add menu item to update access times and remove this as default behavior.

Attachment d2j2d.tar.gz last updated on April 26th, 2012.
[gz] d2j2d-sql.tar.gz (884.8 KB, 673 views)
[gz] d2j2d.tar.gz (11.3 KB, 575 views)
Reply 

#2  dave2008 03-05-2012, 01:29 AM
nice hack :-)
Reply 

#3  JustAMan 03-05-2012, 07:12 AM
Small advice - it would be better to store resulting .db somewhere else (or at least store copies not in /var/local as it easily fills up and thus breaks KT).
Reply 

#4  sumpin 03-05-2012, 08:21 AM
Good point. I updated the script to store the cc.db backups in /mnt/us/system as well.
Reply 

#5  JustAMan 03-05-2012, 09:49 AM
And another idea - for those who don't install SSH it would be impossible to restore backup... Maybe add some menu item that would do exact that?
Reply 

#6  nynaevelan 03-05-2012, 12:55 PM
I've tried running this but it does not seem to be working to put the books into collections. Perhaps I am misunderstanding something. If I put new books on the kindle, then run the kindle collections plugin, then run your script and reboot. Shouldn't it put the new books into the collections based on what the kindles plugin did?
Reply 

#7  sumpin 03-05-2012, 01:56 PM
Quote nynaevelan
I've tried running this but it does not seem to be working to put the books into collections. Perhaps I am misunderstanding something. If I put new books on the kindle, then run the kindle collections plugin, then run your script and reboot. Shouldn't it put the new books into the collections based on what the kindles plugin did?
This is exactly what should happen. I've noticed that every time a new book gets added to cc.db, indexing and who knows what else kicks off. I've noticed that if I import the collections.json from calibre into cc.db before the cpu settles down, some of the books don't show up as in collections. I just re-run the import and all is dandy.

Also, if you're not storing your calibre content in documents/calibre, the script will skip those collections.

Just to prove what a masochist I am, I deleted my cc.db file. A zero length file was immediately created and it took a *long* time before all the content was re-added and re-indexed. When the indexing was done, I ran the export/calibre/import and got all my collections back.

Since stdout and stderr go to /dev/null it's hard to determine what's going wrong. The best bet is to ssh into the Kindle and run json2db.sh -v to see the output.
Reply 

#8  wuschel83 03-06-2012, 05:37 AM
doesn´t work for me, all my folders are invisible now . how can i get them back to my screen???
Reply 

#9  wuschel83 03-06-2012, 05:45 AM
i have delete the cc.db, after this i could start new:
rm /var/local/cc.db
Reply 

#10  sumpin 03-06-2012, 09:44 AM
Quote JustAMan
And another idea - for those who don't install SSH it would be impossible to restore backup... Maybe add some menu item that would do exact that?
Done.
Reply 

  Next »  Last »  (1/7)
Today's Posts | Search this Thread | Login | Register