View Single Post
Old 02-14-2022, 06:53 PM   #1
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
Using fetch-ebook-metadata from a python script

I hope this is in the right forum. If not please let me know.

I am trying to use Calibre's fetch-ebook-metadata command to grab metadata for a book and I am getting some inconsistent results depending on how I run the program.

I am working on an M1 Mac mini with macOS 12.2, running from iterm2.

Running `fetch-ebook-metadata --help` tells me I have the following plugins:

`
All plugin names: Goodreads, Google, Google Images, Amazon.com, Edelweiss, Open Library, Big Book Search
`
If I run

`/Applications/calibre.app/Contents/MacOS/fetch-ebook-metadata --title="Devil House" --author="John Darnielle" -c DevilHouse.jpg -p Goodreads`

I get good metadata, and a cover file.

However, if I run the same command, but from within a Python script using:

Code:
from subprocess import PIPE,run

        CalibreFetchCmd ='/Applications/calibre.app/Contents/MacOS/fetch-ebook-metadata'
        fetchcmd = [CalibreFetchCmd, f'--title="{title}"', f'--author="{author}"', f'-c "{title}-{author}.jpg"-p Goodreads']
        result = run(fetchcmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
I get different data (isbn is different as is the Comments section, for example). These differences are not of particular importance to me. However, from the Python script, I do not get a cover file. Instead, I get:

"Cover : None"

Here is the entire output of the command line invocation:

Quote:
/Applications/calibre.app/Contents/MacOS/fetch-ebook-metadata --title="Devil House" --author="John Darnielle" -c DevilHouse.jpg -p Goodreads
Title : Devil House
Author(s) : John Darnielle
Publisher : MCD
Tags : Horror, Mystery, Adult, Thriller, Contemporary
Languages : eng
Rating : 2
Published : 2022-01-25T00:00:00+00:00
Identifiers : goodreads:57693663, isbn:9780374212230
Comments : <p>Gage Chandler is descended from kings. That's what his mother always told him. </p>
<p>Now, he is a true crime writer, with one grisly success--and movie adaptation--to his name, along with a series of subsequent lesser efforts that have paid the bills but not much more. But now he is being offered the chance for the big break: To move into the house--what the locals call "The Devil House"--in which a briefly notorious pair of murders occurred, apparently the work of disaffected 1980s teens. He begins his research with diligence and enthusiasm, but soon the story leads him into a puzzle he never expected--back into his own work and what it means, back to the very core of what he does and who he is.</p>
Cover : DevilHouse.jpg
And here is the data returned from the Python script:

Quote:
fetchcmd: ['/Applications/calibre.app/Contents/MacOS/fetch-ebook-metadata', '--title="Devil House"',
'--author="John Darnielle"', '-c "Devil House-John Darnielle.jpg" -p Goodreads']
Title : Devil House: A Novel
Author(s) : John Darnielle
Publisher : Farrar, Straus and Giroux
Tags : Fiction, Literary, Crime, World Literature, American, 21st Century
Languages : eng
Published : 2022-01-25T23:50:10.744758+00:00
Identifiers : google:jA8qEAAAQBAJ, isbn:9780374717674
Comments : INSTANT NEW YORK TIMES BESTSELLER“It’s never quite the book you think it is.
It’s better.” —Dwight Garner, The New York TimesFrom John Darnielle, the New York Times bestselling
author and the singer-songwriter of the Mountain Goats, comes an epic, gripping novel about murder,
truth, and the dangers of storytelling.Gage Chandler is descended from kings. That’s what his mother
always told him. Years later, he is a true crime writer, with one grisly success—and a movie
adaptation—to his name, along with a series of subsequent less notable efforts. But now he is being
offered the chance for the big break: to move into the house where a pair of briefly notorious
murders occurred, apparently the work of disaffected teens during the Satanic Panic of the 1980s.
Chandler finds himself in Milpitas, California, a small town whose name rings a bell––his closest
childhood friend lived there, once upon a time. He begins his research with diligence and
enthusiasm, but soon the story leads him into a puzzle he never expected—back into his own work and
what it means, back to the very core of what he does and who he is.Devil House is John Darnielle’s
most ambitious work yet, a book that blurs the line between fact and fiction, that combines daring
formal experimentation with a spellbinding tale of crime, writing, memory, and artistic obsession.
Cover : None
How do I more carefully specify which plugin to use and get the data I desire?
Terry Brown is offline   Reply With Quote