With Peter's help, it looks like you have it worked out. But, the following is what I work with in the driver.
The following is the query that the calibre driver runs:
select Title, Attribution, DateCreated, ContentID, MimeType, ContentType, ImageID, ReadStatus, ___ExpirationStatus, FavouritesIndex, Accessibility, IsDownloaded
where BookID is Null
and Accessibility <> 6
and IsDownloaded in ('true', 1)
and not ((___ExpirationStatus=3 or ___ExpirationStatus is Null) )
That is with preview, expired and recommendations options unchecked.
- Rows with null BookID are describe an actual book. If BookID is not null, it is a chapter in the book.
- Accessibility == 6 is a preview, Accessibility == 4 is a recommendation.
- IsDownloaded in ('true', 1) means the book is in the device. Not true means it is not downloaded which means it is a recommendation. With different firmware, this could be false under
- ContentID = 6 is a book. ContendID = 10 is a newspaper or periodical. The driver doesn't actually use this. I only found out about ContendID = 10 recently. If I remember, I'll add these as a shelf "Newspaper/Periodical" in the device list.
- I'm not completely sure about the ___ExpirationStatus test. This is carried over from the old driver. But, the null rows are the chapter rows. I assume 3 means an expired preview or some other sort of time limited book. If that is right, they probably disappear with the next sync with Kobo.
- ReadStatus: "Im_Reading":1, "Read":2,"Closed":3
- FavouritesIndex was used for older firmware to indicate the book is on the Shortlist. Not used with 2.0.0 or later.
If you exclude anything with a contentId starting with "file:///usr/local/" you will exclude the help which aren't listed in the library. That leaves you with all the "physical" books. Excluding mimeType = "application/x-kobo-epub+zip" will cut out the kepubs.
You can see the query the driver uses if you run calibre in debug mode. Look for "KoboTouch:books - query" in the output.