You have several questions in this and later posts. I will try to deal with them all here.
Quote:
Originally Posted by timlegge
I will probably wait till you merge the new metadata/json code and rework it then.
|
That is probably wise.
Quote:
It seems that device_collections needs to be added to the JSON_ATTRIBUTES in usbms/books.py or the collection is not written to metadata.calibre
|
Device_collections is to be recomputed on each connect (in the driver.books method), which is why it is not written to the cache. Reason: the values can (and do) change, so the cached value could not be trusted.
Quote:
rebuild_collections receives the entire booklist when a device collection is changed. In the case of the Kobo, that leads me to reset and recreate the the I'm Reading list everytime one collection is changed. It does not take long and I may be able to query the device for the collections and only reset the ones that are no longer on the list but that may well be slower.
|
Again, you are right. My thought was that there may be interactions between collections (cross-links or something), and that rebuild_collections should have the entire list to work with.
Quote:
I have not looked at the on send setting and automatic settings. Do they still call rebuild_collections?
|
No. They affect when sync_booklists is called, and what get_collections does.
Manual: sync_booklists is called only when a book is added or removed. Get_collections will compute collections only for books with 'new_book == True'.
On_send: sync_booklists is called only when a book is added or removed. Get_collections will recompute all the collections for all books on the device.
Automatic: sync_booklists is called on every connect. Get_collections will recompute all the collections for all books on the device.
Quote:
Looks like "Only on send" makes use of sync_booklists
|
Sync_booklists is called whenever a book is added or removed. It is to do everything necessary to ensure that the metadata on the device is consistent with the metadata in the booklists. Collection processing is guided as described above.
On the Sony, title & author & author_sort are updated for each book every time sync_booklists is called. This is done because the Sony can decide to reset the author value to what is in the book, undoing the user's request to use author_sort for the author. It can also undo setting the titleSorter field.
For the Kobo, you could choose to use the _new_book flag and the setting of Metadata Management to decide whether or not to update authors etc.
Rebuild_collections is called only when collections are edited on the device view. It should not touch any other metadata. This differs from sync_booklists, which has a free hand to change any metadata as needed.
Quote:
I do like plugging it into Calibre and getting the Reading List overwritten by any books tagged with "I'm Reading". However, getting a book that you are currently reading on the device removed from the reading list (because its not in the Library or tagged) may be less than ideal. What is Calibre's preferred method? Should I overwrite or merge the reading list.
|
As Kovid said, use the value of Metadata Management to decide.
If it is manual, then you do a merge. Never delete a value. Get_collections respects this rule.
If it is on_send or automatic, then calibre's metadata wins. No merging is done. The user must ensure that the tag (or what-have-you) is correct.
One of the differences between on_send and automatic can be seen here. Since on_send does not change the metadata on connect, the user can see the current values in 'Device Collections'. That information can be used to by the user to do a manual merge, setting/clearing the tag as desired. When a book is sent, the tag will win. On 'automatic', the device is asked to change the values on connect, so the existing values will be overwritten. Calibre's data wins.