def make_mobi(book_id, calibrepath): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() data = db.session.query(db.Data).filter(db.Data.book == book.id).filter( db.Data.format == 'EPUB').first() if not data: error_message = _(u"epub format not found for book id: %(book)d", book=book_id) app.logger.error("make_mobi: " + error_message) return error_message, RET_FAIL if ub.config.config_use_google_drive: df = gd.getFileFromEbooksFolder(book.path, data.name + u".epub") if df: datafile = os.path.join(calibrepath, book.path, data.name + u".epub") if not os.path.exists(os.path.join(calibrepath, book.path)): os.makedirs(os.path.join(calibrepath, book.path)) df.GetContentFile(datafile) else: error_message = "make_mobi: epub not found on gdrive: %s.epub" % data.name return error_message, RET_FAIL # else: file_path = os.path.join(calibrepath, book.path, data.name) if os.path.exists(file_path + u".epub"): # convert book, and upload in case of google drive res = converter.convert_mobi(file_path, book) if ub.config.config_use_google_drive: gd.updateGdriveCalibreFromLocal() # time.sleep(10) return res else: error_message = "make_mobi: epub not found: %s.epub" % file_path return error_message, RET_FAIL
def convert_mobi(self): # convert book, and upload in case of google drive self.queue[self.current]['status'] = STAT_STARTED self.UIqueue[self.current]['status'] = _('Started') self.queue[self.current]['starttime'] = datetime.now() self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime'] filename=self.convert() if web.ub.config.config_use_google_drive: gd.updateGdriveCalibreFromLocal() if(filename): self.add_email(_(u'Send to Kindle'), self.queue[self.current]['path'], filename, self.queue[self.current]['settings'], self.queue[self.current]['kindle'], self.UIqueue[self.current]['user'], _(u"E-Mail: %s" % self.queue[self.current]['title']))
def _convert_any_format(self): # convert book, and upload in case of google drive self.UIqueue[self.current]['stat'] = STAT_STARTED self.queue[self.current]['starttime'] = datetime.now() self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime'] curr_task = self.queue[self.current]['taskType'] filename = self._convert_ebook_format() if filename: if web.ub.config.config_use_google_drive: gd.updateGdriveCalibreFromLocal() if curr_task == TASK_CONVERT: self.add_email(self.queue[self.current]['settings']['subject'], self.queue[self.current]['path'], filename, self.queue[self.current]['settings'], self.queue[self.current]['kindle'], self.UIqueue[self.current]['user'], self.queue[self.current]['title'], self.queue[self.current]['settings']['body'])
def _convert_any_format(self): # convert book, and upload in case of google drive self.UIqueue[self.current]['stat'] = STAT_STARTED self.queue[self.current]['starttime'] = datetime.now() self.UIqueue[self.current]['formStarttime'] = self.queue[self.current]['starttime'] curr_task = self.queue[self.current]['taskType'] filename = self._convert_ebook_format() if filename: if web.ub.config.config_use_google_drive: gd.updateGdriveCalibreFromLocal() if curr_task == TASK_CONVERT: self.add_email(self.queue[self.current]['settings']['subject'], self.queue[self.current]['path'], filename, self.queue[self.current]['settings'], self.queue[self.current]['kindle'], self.UIqueue[self.current]['user'], self.queue[self.current]['title'], self.queue[self.current]['settings']['body'])
def convert_any_format(self): # convert book, and upload in case of google drive self.queue[self.current]['status'] = STAT_STARTED self.UIqueue[self.current]['status'] = _('Started') self.queue[self.current]['starttime'] = datetime.now() self.UIqueue[self.current]['formStarttime'] = self.queue[ self.current]['starttime'] curr_task = self.queue[self.current]['typ'] filename = self.convert_ebook_format() if filename: if web.ub.config.config_use_google_drive: gd.updateGdriveCalibreFromLocal() if curr_task == TASK_CONVERT: self.add_email( _(u'Send to Kindle'), self.queue[self.current]['path'], filename, self.queue[self.current]['settings'], self.queue[self.current]['kindle'], self.UIqueue[self.current]['user'], _(u"E-mail: %(book)s", book=self.queue[self.current]['title']))