View Single Post
Old 06-17-2021, 01:41 AM   #6
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
I move the code to a file:

Code:
#!/usr/bin/env python3

from calibre.library import db
from calibre.utils.logging import default_log
from calibre.ebooks.mobi.reader.mobi6 import MobiReader

lib_db = db('~/Calibre Library').new_api
alice_id = 0
for book_id in lib_db.all_book_ids():
    mi = lib_db.get_metadata(book_id)
    if mi.get('title') == "Alice's Adventures in Wonderland":
        alice_id = book_id
        break

book_path = lib_db.format_abspath(alice_id, 'MOBI')
mobiReader = MobiReader(book_path, default_log)
mobiReader.extract_text()
Use calibre-debug to run this code should reproduce the error.

Last edited by xxyzz; 06-17-2021 at 01:45 AM.
xxyzz is offline   Reply With Quote