Add epub, cbz, and fb2 support to pdf controller

This commit is contained in:
Bastian Germann 2019-05-02 15:45:07 +02:00
parent 1c23a1f372
commit 605eadb0c2
3 changed files with 8 additions and 5 deletions

View File

@ -333,7 +333,7 @@ class MessageListener(object):
# the conversion has already been done at this point.
file_type = file_path.suffix.lower()[1:]
if file_type in PDF_CONTROLLER_FILETYPES:
log.debug('Converting from pdf/xps/oxps to images for serviceitem with file {name}'.format(name=file_path))
log.debug('Converting from pdf/xps/oxps/epub/cbz/fb2 to images for serviceitem with file {name}'.format(name=file_path))
# Create a copy of the original item, and then clear the original item so it can be filled with images
item_cpy = copy.copy(item)
item.__init__(None)

View File

@ -42,7 +42,7 @@ except ImportError:
log = logging.getLogger(__name__)
PDF_CONTROLLER_FILETYPES = ['pdf', 'xps', 'oxps']
PDF_CONTROLLER_FILETYPES = ['pdf', 'xps', 'oxps', 'epub', 'cbz', 'fb2']
class PdfController(PresentationController):
@ -128,7 +128,7 @@ class PdfController(PresentationController):
elif program_type == 'mutool':
self.mutoolbin = program_path
elif PYMUPDF_AVAILABLE:
self.also_supports = ['xps', 'oxps']
self.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
return True
else:
# Fallback to autodetection
@ -156,7 +156,7 @@ class PdfController(PresentationController):
elif (application_path / 'mutool').is_file():
self.mutoolbin = application_path / 'mutool'
if self.mudrawbin or self.mutoolbin:
self.also_supports = ['xps', 'oxps']
self.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
return True
elif self.gsbin:
return True

View File

@ -65,7 +65,7 @@ class TestMediaItem(TestCase, TestMixin):
pdf_controller = MagicMock()
pdf_controller.enabled.return_value = True
pdf_controller.supports = ['pdf']
pdf_controller.also_supports = ['xps', 'oxps']
pdf_controller.also_supports = ['xps', 'oxps', 'epub', 'cbz', 'fb2']
# Mock the controllers.
self.media_item.controllers = {
'Impress': impress_controller,
@ -85,6 +85,9 @@ class TestMediaItem(TestCase, TestMixin):
assert '*.pdf' in self.media_item.on_new_file_masks, 'The file mask should contain the pdf extension'
assert '*.xps' in self.media_item.on_new_file_masks, 'The file mask should contain the xps extension'
assert '*.oxps' in self.media_item.on_new_file_masks, 'The file mask should contain the oxps extension'
assert '*.epub' in self.media_item.on_new_file_masks, 'The file mask should contain the epub extension'
assert '*.cbz' in self.media_item.on_new_file_masks, 'The file mask should contain the cbz extension'
assert '*.fb2' in self.media_item.on_new_file_masks, 'The file mask should contain the fb2 extension'
def test_clean_up_thumbnails(self):
"""