Ejemplo n.º 1
0
    def books(self, oncard=None, end_session=True):

        log.debug("Reading {}".format(oncard))

        bl = super(MUSE, self).books(oncard, end_session)

        if self.bookeen_database is None:
            log.debug("Looking for device databases")

            main_lib = "{}/system/library".format(self.driveinfo['main']['prefix'])
            carda_lib = None
            if 'A' in self.driveinfo.keys():
                carda_lib = "{}/system/library".format(self.driveinfo['A']['prefix'])

            log.debug("device databases: {}, {}".format(main_lib, carda_lib))
            self.bookeen_database = BookeenDatabase(main_lib, carda_lib)

        try:
            to_close, self.to_set_as_read = self.bookeen_database.match(oncard, bl, int(self.settings().extra_customization[self.OPT_CLOSE_THRESHOLD]))

            if int(self.settings().extra_customization[self.OPT_CLOSE_THRESHOLD]) > 0:
                if to_close:
                    log.debug("to close: {}".format(to_close))
                else:
                    log.debug("Nothing to close")
            else:
                log.debug("Threshold is zero: disabled closing books")
        except BookeenDatabaseException, e:
            log.debug(e)
Ejemplo n.º 2
0
class MuseEx(MUSE):
    name = 'Cybook Muse Ex Device Interface'
    gui_name = 'Muse Ex'
    description = _('Communicate with the Cybook Odyssey / Muse / Ocean eBook reader.')
    author = 'Nicolas Briche'
    version = (0, 0, 3)

    booklist_class = BookList
    book_class = BookeenBook

    FORMATS = ['epub', 'html', 'fb2', 'txt', 'pdf', 'djvu']

    VENDOR_ID = [0x0525]
    PRODUCT_ID = [0xa4a5]
    BCD = [0x0230]

    VENDOR_NAME = 'USB_2.0'
    WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'USB_FLASH_DRIVER'

    EBOOK_DIR_MAIN = 'Digital Editions'
    EBOOK_DIR_CARD_A = 'Digital Editions'

    EXTRA_CUSTOMIZATION_MESSAGE = [
        _('Card A folder') + ':::<p>' +
        _('Enter the folder where the books are to be stored when sent to the '
          'memory card. This folder is prepended to any send to device template') + '</p>',
        _('"Obsolete" custom field') + ':::<p>' +
        _('Select which field to update to \'Yes\' when an obsolete book is detected (Calibre has a more recent copy of that book).') + '</p>',
        _('"Read" custom field') + ':::<p>' +
        _('Select which fields to update to \'Yes\' when a read book is detected.  The first field will be unset when the book is removed.  Any following fields will not be unset.') + '</p>',
        _('Current page threshold for closing a book') + ':::<p>' +
        _('If you open a book, the device considers it as "currently reading", even if you only read the cover.  Calibre will close any book whose current page is under this field\'s value, and reset it to "New".  Set to 0 to disable.') + '</p>',
    ]
    EXTRA_CUSTOMIZATION_DEFAULT = [EBOOK_DIR_CARD_A, "", "", "0"]

    OPT_OBSOLETE_COLUMN = 1
    OPT_UPDATE_READ_COLUMNS = 2
    OPT_CLOSE_THRESHOLD = 3

    SCAN_FROM_ROOT = False

    bookeen_database = None
    can_set_as_read = False
    to_set_as_read = []
    set_as_read_fields = None

    def books(self, oncard=None, end_session=True):

        log.debug("Reading {}".format(oncard))

        bl = super(MUSE, self).books(oncard, end_session)

        if self.bookeen_database is None:
            log.debug("Looking for device databases")

            main_lib = "{}/system/library".format(self.driveinfo['main']['prefix'])
            carda_lib = None
            if 'A' in self.driveinfo.keys():
                carda_lib = "{}/system/library".format(self.driveinfo['A']['prefix'])

            log.debug("device databases: {}, {}".format(main_lib, carda_lib))
            self.bookeen_database = BookeenDatabase(main_lib, carda_lib)

        try:
            to_close, self.to_set_as_read = self.bookeen_database.match(oncard, bl, int(self.settings().extra_customization[self.OPT_CLOSE_THRESHOLD]))

            if int(self.settings().extra_customization[self.OPT_CLOSE_THRESHOLD]) > 0:
                if to_close:
                    log.debug("to close: {}".format(to_close))
                else:
                    log.debug("Nothing to close")
            else:
                log.debug("Threshold is zero: disabled closing books")
        except BookeenDatabaseException, e:
            log.debug(e)

        return bl