mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement bug #4423: Sony Reader user defined collections from metdata.
This commit is contained in:
parent
1969ba074f
commit
fc7baaabd9
@ -180,7 +180,7 @@ class BookList(_BookList):
|
||||
return child
|
||||
return None
|
||||
|
||||
def add_book(self, mi, name, size, ctime):
|
||||
def add_book(self, mi, name, collections, size, ctime):
|
||||
""" Add a node into the DOM tree, representing a book """
|
||||
book = self.book_by_path(name)
|
||||
if book is not None:
|
||||
@ -221,12 +221,18 @@ class BookList(_BookList):
|
||||
book = Book(node, self.mountpath, [], prefix=self.prefix)
|
||||
book.datetime = ctime
|
||||
self.append(book)
|
||||
|
||||
tags = []
|
||||
if mi.tags:
|
||||
tags.extend(mi.tags)
|
||||
if mi.series:
|
||||
tags.append(mi.series)
|
||||
for item in collections:
|
||||
item = item.strip()
|
||||
mitem = getattr(mi, item, None)
|
||||
if mitem:
|
||||
if isinstance(mitem, list):
|
||||
tags.extend(mitem)
|
||||
else:
|
||||
tags.append(mitem)
|
||||
if tags:
|
||||
tags = list(set(tags))
|
||||
if hasattr(mi, 'tag_order'):
|
||||
self.tag_order.update(mi.tag_order)
|
||||
self.set_tags(book, tags)
|
||||
|
@ -55,6 +55,10 @@ class PRS505(CLI, Device):
|
||||
MUST_READ_METADATA = True
|
||||
EBOOK_DIR_MAIN = 'database/media/books'
|
||||
|
||||
EXTRA_CUSTOMIZATION_MESSAGE = _('Comma separated list of metadata fields '
|
||||
'to turn into collections on the device.')
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = ', '.join(['series', 'tags'])
|
||||
|
||||
def windows_filter_pnp_id(self, pnp_id):
|
||||
return '_LAUNCHER' in pnp_id
|
||||
|
||||
@ -159,7 +163,8 @@ class PRS505(CLI, Device):
|
||||
if name.startswith('/'):
|
||||
name = name[1:]
|
||||
|
||||
booklists[blist].add_book(info, name, *location[1:-1])
|
||||
opts = self.settings()
|
||||
booklists[blist].add_book(info, name, opts.extra_customization.split(','), *location[1:-1])
|
||||
fix_ids(*booklists)
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user