mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Properly hande user trying to add .kobo books to calibre from device
This commit is contained in:
parent
b0b904fbf1
commit
9bd69f1437
@ -52,6 +52,11 @@ class DevicePlugin(Plugin):
|
|||||||
#: long time
|
#: long time
|
||||||
OPEN_FEEDBACK_MESSAGE = None
|
OPEN_FEEDBACK_MESSAGE = None
|
||||||
|
|
||||||
|
#: Set of extensions that are "virtual books" on the device
|
||||||
|
#: and therefore cannot be viewed/saved/added to library
|
||||||
|
#: For example: ``frozenset(['kobo'])``
|
||||||
|
VIRTUAL_BOOK_EXTENSIONS = frozenset([])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_gui_name(cls):
|
def get_gui_name(cls):
|
||||||
if hasattr(cls, 'gui_name'):
|
if hasattr(cls, 'gui_name'):
|
||||||
|
@ -38,6 +38,8 @@ class KOBO(USBMS):
|
|||||||
EBOOK_DIR_MAIN = ''
|
EBOOK_DIR_MAIN = ''
|
||||||
SUPPORTS_SUB_DIRS = True
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
|
VIRTUAL_BOOK_EXTENSIONS = frozenset(['kobo'])
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
USBMS.initialize(self)
|
USBMS.initialize(self)
|
||||||
self.book_class = Book
|
self.book_class = Book
|
||||||
|
@ -430,6 +430,20 @@ class AddAction(object): # {{{
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
return
|
return
|
||||||
paths = [p for p in view._model.paths(rows) if p is not None]
|
paths = [p for p in view._model.paths(rows) if p is not None]
|
||||||
|
ve = self.device_manager.device.VIRTUAL_BOOK_EXTENSIONS
|
||||||
|
def ext(x):
|
||||||
|
ans = os.path.splitext(x)[1]
|
||||||
|
ans = ans[1:] if len(ans) > 1 else ans
|
||||||
|
return ans.lower()
|
||||||
|
remove = set([p for p in paths if ext(p) in ve])
|
||||||
|
if remove:
|
||||||
|
paths = [p for p in paths if p not in remove]
|
||||||
|
info_dialog(self, _('Not Implemented'),
|
||||||
|
_('The following books are virtual and cannot be added'
|
||||||
|
' to the calibre library:'), '\n'.join(remove),
|
||||||
|
show=True)
|
||||||
|
if not paths:
|
||||||
|
return
|
||||||
if not paths or len(paths) == 0:
|
if not paths or len(paths) == 0:
|
||||||
d = error_dialog(self, _('Add to library'), _('No book files found'))
|
d = error_dialog(self, _('Add to library'), _('No book files found'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user