Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-04-2025, 05:35 AM   #1
Salvodif
Junior Member
Salvodif began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2021
Device: Kindle, Android
Python libraries

hello,
i would need some libraries to be able to download the metadata of my books saved on calibre using python.

I tried using the example on the site but it doesn't find the library

Code:
import pprint

from calibre.library import db
from datetime import datetime

sys.path.append(os.path.abspath("../BibliothecaProcurator"))
from BibliothecaProcurator import BibliothecaProcurator
from book import Book

class CalibreLibraryReader:
    def __init__(self, calibre_library_path: str):
        """
        Inizializza la connessione alla libreria Calibre
        
        :param calibre_library_path: Percorso alla cartella della libreria Calibre
        """
        self.calibre_db = db("C:\\Users\\salva\\DBCalibre")

    def get_all_books(self):
        """
        Recupera tutti i libri dalla libreria Calibre
        """
        books = []
        for book_id in self.calibre_db.all_ids():
            metadata = self.calibre_db.get_metadata(book_id)
            last_modified = datetime.fromtimestamp(self.calibre_db.last_modified(book_id))
            
            book = Book(
                title=metadata.title,
                authors=metadata.authors,
                tags=metadata.tags or [],
                uuid=str(metadata.uuid),
                path=self.calibre_db.format_abspath(book_id, 'EPUB') or '',
                created=last_modified,
                data_modified=last_modified
            )
            books.append(book)
            pprint(book)
Salvodif is offline   Reply With Quote
Old 04-04-2025, 07:58 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need to use an absolute path to your library folder as you have no control over what the current working directory is and hence what .. will resolve to
kovidgoyal is offline   Reply With Quote
Advert
Old 04-04-2025, 08:51 AM   #3
Salvodif
Junior Member
Salvodif began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2021
Device: Kindle, Android
Quote:
Originally Posted by kovidgoyal View Post
You need to use an absolute path to your library folder as you have no control over what the current working directory is and hence what .. will resolve to
what that means pratically ?
Salvodif is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting ePub Python coding books to PDF outputs Python code far too small lysakowski Conversion 9 04-30-2023 05:44 AM
Copying books between libraries where MANY libraries exist tomwitt Library Management 1 06-01-2020 06:24 PM
Is the environment Python 2 or Python 3? halloleo Library Management 11 04-07-2020 03:47 AM
Python 2 to Python 3, Polyglot & Plugins DaltonST Calibre 18 04-24-2019 12:10 AM
Python Libraries included in Plugin? JimmXinu Development 5 06-15-2014 06:48 AM


All times are GMT -4. The time now is 03:23 AM.


MobileRead.com is a privately owned, operated and funded community.