View Single Post
Old 07-08-2021, 05:11 PM   #4
Terry Brown
Enthusiast
Terry Brown began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Jun 2010
Location: Portland, OR
Device: M1 Max Mac Studio, iPad Pro 2018 12.9, iPhone 7
Thanks for the replies.

I do use calibredb, called from python. I use 'list -f all --for-machine' as options to get the entire calibre database as json. Then I create the path to the cover file for a book by concatenating the library path on my Mac with the 'authors', 'title', 'id' fields taken directly from the json data.

But when I do so, the path created has characters in it that result in a "file not found" error when I use the path to call Image.open():

Code:
im = Image.open(calibrecoverpath)
That's why I'm confused. The files on disk are accessible to me from Finder or the command line, so the names must be sanitized, but the data from calibredb that I get as json is apparently not.

I manipulate (both read and write) the calibre database using calibredb from within my program in many other ways. In this case, I just want to grab the cover file so I can display it with my program when I show reading stats on a book. I don't see a way to directly get the path to the cover file from calibredb, so I use the individual fields (author, title) to create the path.

What should I do instead?
Terry Brown is offline   Reply With Quote