View Single Post
Old 03-25-2020, 09:36 PM   #22
vikarti
Groupie
vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.vikarti ought to be getting tired of karma fortunes by now.
 
Posts: 185
Karma: 1004974
Join Date: May 2013
Location: Solar system, Earth
Device: none
Quote:
Originally Posted by evans View Post
If a book has multiple formats in Calibre, which are synced to BookFusion?
As far as I understood how this works based on my experience with plugin:
if EPUB or MOBI is present - it's being used
if they are not present but 'AZW', 'AZW3', 'AZW4', 'CBZ', 'CBR', 'CBC', 'CHM', 'DJVU', 'DOCX', 'EPUB', 'FB2', 'FBZ', 'HTML', 'HTMLZ', 'LIT', 'LRF', 'MOBI', 'ODT', 'PDF', 'PRC', 'PDB', 'PML', 'RB', 'RTF', 'SNB', 'TCR', 'TXT', 'TXTZ' are present - they are being used. Backend will convert file to readable by clients.

Code:
class BookFormat:
    SUPPORTED_FMTS = [
        'AZW', 'AZW3', 'AZW4', 'CBZ', 'CBR', 'CBC', 'CHM', 'DJVU', 'DOCX', 'EPUB', 'FB2', 'FBZ', 'HTML', 'HTMLZ',
        'LIT', 'LRF', 'MOBI', 'ODT', 'PDF', 'PRC', 'PDB', 'PML', 'RB', 'RTF', 'SNB', 'TCR', 'TXT', 'TXTZ'
    ]
    PREFERRED_FMTS = ['EPUB', 'MOBI']

    def __init__(self, db, book_id):
        self.file_path = None
        self.fmt = None

        fmts = db.formats(book_id)
        if len(fmts) > 0:
            fmt = fmts[0]
            for preferred_fmt in self.PREFERRED_FMTS:
                if preferred_fmt in fmts:
                    fmt = preferred_fmt
                    break

            if fmt in self.SUPPORTED_FMTS:
                self.fmt = fmt
                self.file_path = db.format_abspath(book_id, fmt)

Last edited by vikarti; 05-12-2020 at 07:32 AM.
vikarti is offline   Reply With Quote