diff --git a/src/calibre/devices/cybookg3/driver.py b/src/calibre/devices/cybookg3/driver.py index cdc41d3aca..8f58c65ae7 100644 --- a/src/calibre/devices/cybookg3/driver.py +++ b/src/calibre/devices/cybookg3/driver.py @@ -48,9 +48,9 @@ class CYBOOKG3(USBMS): def upload_cover(self, path, filename, metadata): coverdata = getattr(metadata, 'thumbnail', None) - if coverdata: + if coverdata and coverdata[2]: with open('%s_6090.t2b' % os.path.join(path, filename), 'wb') as t2bfile: - t2b.write_t2b(t2bfile, coverdata) + t2b.write_t2b(t2bfile, coverdata[2]) @classmethod def can_handle(cls, device_info, debug=False): diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index d8c22170f5..a774ed37ed 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -276,7 +276,9 @@ class DevicePlugin(Plugin): The idea is to use the metadata to determine where on the device to put the book. len(metadata) == len(files). Apart from the regular cover_data, there may also be a thumbnail attribute, which should - be used in preference. + be used in preference. The thumbnail attribute is of the form + (width, height, cover_data as jpeg). In addition the MetaInformation + objects can have a tag_order attribute. ''' raise NotImplementedError() @@ -286,17 +288,8 @@ class DevicePlugin(Plugin): Add locations to the booklists. This function must not communicate with the device. @param locations: Result of a call to L{upload_books} - @param metadata: List of dictionaries. Each dictionary must have the - keys C{title}, C{authors}, C{author_sort}, C{cover}, C{tags}. - The value of the C{cover} - element can be None or a three element tuple (width, height, data) - where data is the image data in JPEG format as a string. C{tags} must be - a possibly empty list of strings. C{authors} must be a string. - C{author_sort} may be None. It is upto the driver to decide whether to - use C{author_sort} or not. - The dictionary can also have an optional key "tag order" which should be - another dictionary that maps tag names to lists of book ids. The ids are - ids from the book database. + @param metadata: List of MetaInformation objects, same as for + :method:`upload_books`. @param booklists: A tuple containing the result of calls to (L{books}(oncard=None), L{books}(oncard='carda'), L{books}(oncard='cardb')). diff --git a/src/calibre/devices/nook/driver.py b/src/calibre/devices/nook/driver.py index fc28363bff..c74a964648 100644 --- a/src/calibre/devices/nook/driver.py +++ b/src/calibre/devices/nook/driver.py @@ -54,8 +54,8 @@ class NOOK(USBMS): coverdata = getattr(metadata, 'thumbnail', None) - if coverdata: - cover = Image.open(cStringIO.StringIO(coverdata)) + if coverdata and coverdata[2]: + cover = Image.open(cStringIO.StringIO(coverdata[2])) else: coverdata = open(I('library.png'), 'rb').read() diff --git a/src/calibre/devices/prs505/books.py b/src/calibre/devices/prs505/books.py index 6e268e734a..227356bda9 100644 --- a/src/calibre/devices/prs505/books.py +++ b/src/calibre/devices/prs505/books.py @@ -180,7 +180,7 @@ class BookList(_BookList): return child return None - def add_book(self, info, name, size, ctime): + def add_book(self, mi, name, size, ctime): """ Add a node into the DOM tree, representing a book """ book = self.book_by_path(name) if book is not None: @@ -194,9 +194,9 @@ class BookList(_BookList): except: sourceid = '1' attrs = { - "title" : info["title"], - 'titleSorter' : sortable_title(info['title']), - "author" : info["authors"] if info['authors'] else _('Unknown'), + "title" : mi.title, + 'titleSorter' : sortable_title(mi.title), + "author" : mi.format_authors() if mi.format_authors() else _('Unknown'), "page":"0", "part":"0", "scale":"0", \ "sourceid":sourceid, "id":str(cid), "date":"", \ "mime":mime, "path":name, "size":str(size) @@ -205,8 +205,8 @@ class BookList(_BookList): node.setAttributeNode(self.document.createAttribute(attr)) node.setAttribute(attr, attrs[attr]) try: - w, h, data = info["cover"] - except TypeError: + w, h, data = mi.thumbnail + except: w, h, data = None, None, None if data: @@ -221,10 +221,15 @@ class BookList(_BookList): book = Book(node, self.mountpath, [], prefix=self.prefix) book.datetime = ctime self.append(book) - if info.has_key('tags'): - if info.has_key('tag order'): - self.tag_order.update(info['tag order']) - self.set_tags(book, info['tags']) + tags = [] + if mi.tags: + tags.extend(mi.tags) + if mi.series: + tags.append(mi.series) + if tags: + if hasattr(mi, 'tag_order'): + self.tag_order.update(mi.tag_order) + self.set_tags(book, tags) def _delete_book(self, node): nid = node.getAttribute('id') diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 6463d11daa..70f75917be 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -400,7 +400,13 @@ class BooksModel(QAbstractTableModel): return data def metadata_for(self, ids): - return [self.db.get_metadata(id, index_is_id=True) for id in ids] + ans = [] + for id in ids: + mi = self.db.get_metadata(id, index_is_id=True) + if mi.series is not None: + mi.tag_order = self.db.books_in_series_of(id, index_is_id=True) + ans.append(mi) + return ans def get_metadata(self, rows, rows_are_ids=False, full_metadata=False): metadata, _full_metadata = [], []