|
|
#1 |
|
Junior Member
![]() 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)
|
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,610
Karma: 28549044
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
|
|
|
|
|
|
#3 |
|
Junior Member
![]() Posts: 9
Karma: 10
Join Date: May 2021
Device: Kindle, Android
|
|
|
|
|
![]() |
|
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 06:44 AM |
| Copying books between libraries where MANY libraries exist | tomwitt | Library Management | 1 | 06-01-2020 07:24 PM |
| Is the environment Python 2 or Python 3? | halloleo | Library Management | 11 | 04-07-2020 04:47 AM |
| Python 2 to Python 3, Polyglot & Plugins | DaltonST | Calibre | 18 | 04-24-2019 01:10 AM |
| Python Libraries included in Plugin? | JimmXinu | Development | 5 | 06-15-2014 07:48 AM |