View Single Post
Old 10-24-2013, 01:46 PM   #10
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,104
Karma: 5005503
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by chaley View Post
I am using the book's UUID (unique ID) and the extension of the format file to determine whether a book is in the cache. Unfortunately that will fail if the same format of the same book is on the device more than once, which can happen if you are naming books in the normal calibre fashion. Example: "Tempest, The.epub" and "The Tempest.epub" could both be on the device. As it is today, the cache will contain one of these and both books from the device will match that book. You would not see duplicates, and I think that the metadata for one of the books will not be updated.
I have seen that behavior, but it's not the main problem I was having.

I did see duplicate books on my devices of the form "Tempest, The.epub" and "The Tempest.epub". Deleting all the books without files cleared most or all of them, however. I think I have a 1 book discrepancy on one device now.

The main problem I was having was very clearly to do with the thumbnail size. I added _debug calls to _metadata_already_on_device in calibre/devices/smart_device_app/driver.py and it was clear: One device wanted thumbnails 320px high and the other 160px high and the thumbnail in calibre was which ever was called for last.

Spoiler:

Code:
    def _metadata_already_on_device(self, book):
        try:
            v = self.known_metadata.get(book.lpath, None)
            if v is not None:
                if v.get('uuid', None) != book.get('uuid', None):
                    self._debug("uuid(v:%s book:%s"%(v.get('uuid', None),book.get('uuid', None)))
                if v.get('last_modified', None) != book.get('last_modified', None):
                    self._debug("last_modified(v:%s book:%s"%(v.get('last_modified', None),book.get('last_modified', None)))
                # Metadata is the same if the uuids match, if the last_modified dates
                # match, and if the height of the thumbnails is the same. The last
                # is there to allow a device to demand a different thumbnail size
                if (v.get('uuid', None) == book.get('uuid', None) and
                        v.get('last_modified', None) == book.get('last_modified', None)):
                    v_thumb = v.get('thumbnail', None)
                    b_thumb = book.get('thumbnail', None)
                    if bool(v_thumb) != bool(b_thumb):
                        self._debug("thumbnail(v:%s book:%s"%(bool(v.get('thumbnail', None)),bool(book.get('thumbnail', None))))
                        return False
                    if v_thumb==None or v_thumb[1] != b_thumb[1]:
                        self._debug("thumbnail(v:%s v[1]:%s book[1]:%s"%(bool(v_thumb), v_thumb[1], b_thumb[1]))
                    return not v_thumb or v_thumb[1] == b_thumb[1]
            else:
                self._debug("v:None")
        except:
            traceback.print_exc()
        return False
Output:
Code:
SMART_DEV (  81.61:  0.000) _metadata_already_on_device thumbnail(v:True v[1]:320 book[1]:160
SMART_DEV (  81.63:  0.000) _metadata_already_on_device thumbnail(v:True v[1]:320 book[1]:160
SMART_DEV (  81.64:  0.000) _metadata_already_on_device thumbnail(v:True v[1]:320 book[1]:160
... (repeat many times) ...
... then when connecting other device ...
SMART_DEV ( 350.12:  0.269) _metadata_already_on_device thumbnail(v:True v[1]:160 book[1]:320
SMART_DEV ( 350.14:  0.000) _metadata_already_on_device thumbnail(v:True v[1]:160 book[1]:320
SMART_DEV ( 350.15:  0.000) _metadata_already_on_device thumbnail(v:True v[1]:160 book[1]:320
... (repeat many times) ...

Changing the thumbnail size to 'Medium' for all uses on both devices works around it for now.
JimmXinu is offline   Reply With Quote