def auto_convert_auto_add(self, book_ids): previous = self.gui.library_view.currentIndex() db = self.gui.current_db needed = set() of = prefs['output_format'].lower() for book_id in book_ids: fmts = db.formats(book_id, index_is_id=True) fmts = set(x.lower() for x in fmts.split(',')) if fmts else set() if gprefs['auto_convert_same_fmt'] or of not in fmts: needed.add(book_id) if needed: jobs, changed, bad = convert_single_ebook( self.gui, self.gui.library_view.model().db, needed, True, of, show_no_format_warning=False) if not jobs: return self.queue_convert_jobs(jobs, changed, bad, list(needed), previous, self.book_converted, rows_are_ids=True)
def auto_convert_news(self, book_ids, format): previous = self.gui.library_view.currentIndex() rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()] jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format) if jobs == []: return self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_auto_converted_news)
def do_convert(self, book_ids, bulk=None): previous = self.gui.library_view.currentIndex() rows = [ x.row() for x in self.gui.library_view.selectionModel().selectedRows() ] num = 0 if bulk or (bulk is None and len(book_ids) > 1): self.__bulk_queue = convert_bulk_ebook( self.gui, self.queue_convert_jobs, self.gui.library_view.model().db, book_ids, out_format=prefs['output_format'], args=(rows, previous, self.book_converted)) if self.__bulk_queue is None: return num = len(self.__bulk_queue.book_ids) else: jobs, changed, bad = convert_single_ebook( self.gui, self.gui.library_view.model().db, book_ids, out_format=prefs['output_format']) self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_converted) num = len(jobs) if num > 0: self.gui.jobs_pointer.start() self.gui.status_bar.show_message( ngettext('Starting conversion of the book', 'Starting conversion of {} books', num).format(num), 2000)
def convert_ebook(self, checked, bulk=None): book_ids = self.get_books_for_conversion() if book_ids is None: return previous = self.gui.library_view.currentIndex() rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()] num = 0 if bulk or (bulk is None and len(book_ids) > 1): self.__bulk_queue = convert_bulk_ebook( self.gui, self.queue_convert_jobs, self.gui.library_view.model().db, book_ids, out_format=prefs["output_format"], args=(rows, previous, self.book_converted), ) if self.__bulk_queue is None: return num = len(self.__bulk_queue.book_ids) else: jobs, changed, bad = convert_single_ebook( self.gui, self.gui.library_view.model().db, book_ids, out_format=prefs["output_format"] ) self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_converted) num = len(jobs) if num > 0: self.gui.jobs_pointer.start() self.gui.status_bar.show_message(_("Starting conversion of %d book(s)") % num, 2000)
def auto_convert_multiple_mail(self, book_ids, data, ofmt, delete_from_library): previous = self.gui.library_view.currentIndex() rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()] jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, ofmt) if jobs == []: return self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_auto_converted_multiple_mail, extra_job_args=[delete_from_library, data])
def auto_convert(self, book_ids, on_card, format): previous = self.gui.library_view.currentIndex() rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()] jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format) if jobs == []: return self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_auto_converted, extra_job_args=[on_card])
def auto_convert_auto_add(self, book_ids): previous = self.gui.library_view.currentIndex() db = self.gui.current_db needed = set() of = prefs["output_format"].lower() for book_id in book_ids: fmts = db.formats(book_id, index_is_id=True) fmts = set(x.lower() for x in fmts.split(",")) if fmts else set() if of not in fmts: needed.add(book_id) if needed: jobs, changed, bad = convert_single_ebook( self.gui, self.gui.library_view.model().db, needed, True, of, show_no_format_warning=False ) if not jobs: return self.queue_convert_jobs(jobs, changed, bad, list(needed), previous, self.book_converted, rows_are_ids=True)
def convert_vtt_files(self): main_lang = self.main_lang_combo.currentData() if main_lang == '-': QMessageBox.about(self, 'Information', 'Select the main language before conversion.') return sub_lang = str(self.sub_lang_combo.currentData()) # if user does not select sub_lang, set it to main_lang, so that when converting, it won't generate sub language. if sub_lang == '-': sub_lang = main_lang # convert to html if hasattr(self, 'cover_file_path'): cover_file_path = self.cover_file_path else: cover_file_path = None self.book_id = self.convert_to_html_add_to_library( self.vtt_dir, main_lang, sub_lang, cover_file_path) # add html to epub conversion job self.jobs, changed, bad = convert_single_ebook( self.gui, self.gui.library_view.model().db, [self.book_id], True, self.outputFmt) func, args, desc, fmt, id, temp_files = self.jobs[0] core_usage = 1 plugin = plugin_for_input_format('html') if plugin is not None: core_usage = plugin.core_usage self.gui.job_manager.run_job(Dispatcher(self.converted_func), func, args=args, description=desc, core_usage=core_usage) self.close()
def do_convert(self, book_ids, bulk=None): previous = self.gui.library_view.currentIndex() rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()] num = 0 if bulk or (bulk is None and len(book_ids) > 1): self.__bulk_queue = convert_bulk_ebook(self.gui, self.queue_convert_jobs, self.gui.library_view.model().db, book_ids, out_format=prefs['output_format'], args=(rows, previous, self.book_converted)) if self.__bulk_queue is None: return num = len(self.__bulk_queue.book_ids) else: jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, out_format=prefs['output_format']) self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_converted) num = len(jobs) if num > 0: self.gui.jobs_pointer.start() self.gui.status_bar.show_message(ngettext( 'Starting conversion of the book', 'Starting conversion of {} books', num).format(num), 2000)