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 child
|
||||||
return None
|
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 """
|
""" Add a node into the DOM tree, representing a book """
|
||||||
book = self.book_by_path(name)
|
book = self.book_by_path(name)
|
||||||
if book is not None:
|
if book is not None:
|
||||||
@ -221,12 +221,18 @@ class BookList(_BookList):
|
|||||||
book = Book(node, self.mountpath, [], prefix=self.prefix)
|
book = Book(node, self.mountpath, [], prefix=self.prefix)
|
||||||
book.datetime = ctime
|
book.datetime = ctime
|
||||||
self.append(book)
|
self.append(book)
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
if mi.tags:
|
for item in collections:
|
||||||
tags.extend(mi.tags)
|
item = item.strip()
|
||||||
if mi.series:
|
mitem = getattr(mi, item, None)
|
||||||
tags.append(mi.series)
|
if mitem:
|
||||||
|
if isinstance(mitem, list):
|
||||||
|
tags.extend(mitem)
|
||||||
|
else:
|
||||||
|
tags.append(mitem)
|
||||||
if tags:
|
if tags:
|
||||||
|
tags = list(set(tags))
|
||||||
if hasattr(mi, 'tag_order'):
|
if hasattr(mi, 'tag_order'):
|
||||||
self.tag_order.update(mi.tag_order)
|
self.tag_order.update(mi.tag_order)
|
||||||
self.set_tags(book, tags)
|
self.set_tags(book, tags)
|
||||||
|
@ -55,6 +55,10 @@ class PRS505(CLI, Device):
|
|||||||
MUST_READ_METADATA = True
|
MUST_READ_METADATA = True
|
||||||
EBOOK_DIR_MAIN = 'database/media/books'
|
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):
|
def windows_filter_pnp_id(self, pnp_id):
|
||||||
return '_LAUNCHER' in pnp_id
|
return '_LAUNCHER' in pnp_id
|
||||||
|
|
||||||
@ -159,7 +163,8 @@ class PRS505(CLI, Device):
|
|||||||
if name.startswith('/'):
|
if name.startswith('/'):
|
||||||
name = name[1:]
|
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)
|
fix_ids(*booklists)
|
||||||
|
|
||||||
def delete_books(self, paths, end_session=True):
|
def delete_books(self, paths, end_session=True):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user