2

I'm looking for a way to access the contents of my kindle using objective-c. Specifically I'd like to:

  • List the documents on the device
  • Add and remove documents
  • Manage collections (add and remove documents, etc..)

I know that Calibre does all this (and more) but it's in Java.

It's the first time I've ever tried to access a device of any type from a Cocoa app. If anyone has any ideas or starting points I'd really appreciate it.

Jonno
  • 23
  • 2
  • 2
    I'd think you'd get by with making filesystem calls with [NSFileManager](http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/cl/NSFileManager), since the Kindle itself usually gets mounted as a disk in `/Volumes`. Not sure about managing collections — [this plugin](http://www.mobileread.com/forums/showthread.php?t=118635) gives Calibre support for doing so, but it looks to be broken with the Kindle Touch. – Ben Kreeger May 10 '13 at 13:31
  • Ah yes, I see. I can see the documents on the kindle volume, and the collections.json that presumably defines the collections on the device. I'll start investigating. Thanks so much for your help. – Jonno May 10 '13 at 13:48
  • Sure! I guess I'll post that as an answer, then, and if you're happy with it, you can mark it as the accepted answer. – Ben Kreeger May 10 '13 at 15:23

1 Answers1

0

You can probably get by with making basic filesystem calls with NSFileManager, since the Kindle itself usually gets mounted as a disk in /Volumes. You can then pull file metadata that way to get book titles and authors and stuff.

Edit: @Peter Hosey brings a good point:

Note: Don't assume that all mounted volumes are in /Volumes. Administrators can mount any device anywhere, fstab may be set up to mount a specific device in a specific place, and Apple could always radically change the file-system layout. Use NSFileManager's mountedVolumeURLsIncludingResourceValuesForKeys:options: method or Disk Arbitration to find all of the mounted volumes, wherever they are.

Not sure about managing collections, though. This plugin gives Calibre support for doing so, but it looks to be broken with the Kindle Touch. Collections seem to be a Kindle-proprietary thing that are likely stored in that collections.json file. Sounds like the Kindle Touch changed the game, though, and you won't be able to manage collections on it (unless Amazon decides to release some sort of SDK to simplify the whole process, but I wouldn't hold my breath).

The Kindle Touch holds its collections file at /var/local/cc.db, which I'm betting is some sort of SQLite file. Sadly you can only get to it by jailbreaking your Kindle Touch. This tool sounds like it may give you some insight, but since this has changed on the Touch, you're looking at making special cases for collection management based on the device type. Best of luck to you (if you're making a Cocoa-based Kindle manager, I would love to throw money at you when finished)!

Ben Kreeger
  • 6,355
  • 2
  • 38
  • 53
  • 1
    Note: Don't assume that all mounted volumes are in /Volumes. Administrators can mount any device anywhere, `fstab` may be set up to mount a specific device in a specific place, and Apple could always radically change the file-system layout. Use NSFileManager's `mountedVolumeURLsIncludingResourceValuesForKeys:options:` method or Disk Arbitration to find all of the mounted volumes, wherever they are. – Peter Hosey May 10 '13 at 21:12
  • @Peter Hosey: thanks! I've never run into that situation; I had no idea it was even possible (and a method name is great; wasn't sure of what it was). Up-voted (and I'll modify my answer). – Ben Kreeger May 11 '13 at 00:37