Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
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
Old 02-14-2022, 08:37 PM   #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,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You are not serializing the command line arguments properly in your python script. You want something like

['--title', title, '-c', cover_path, etc]
kovidgoyal is offline   Reply With Quote
Advert
Old 02-17-2022, 08:31 AM   #3
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
I played around a bit with how I presented th parameters in the list to the subprocess.run() command, and got varying results. I tried this again on your suggestion, and I do see the cover file downloaded, but I still see some inconsistencies. I’ll do some more rigorous testing to figure out where I went wrong.

Thanks for the help.
Terry Brown is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on fetch-ebook-metadata behavior johnmcd Library Management 2 10-24-2021 11:00 AM
Using calibredb and fetch-ebook-metadata to fix invalidly identified books EldonMcGuinness Library Management 4 08-01-2019 01:10 PM
New fetch-ebook-metadata errors plo233 Calibre 6 08-24-2018 11:14 PM
fetch-ebook-metadata.exe python error dzog Calibre 2 11-04-2016 05:26 AM
Import ebook conversion in python script erollisi Calibre 1 08-19-2010 09:43 PM


All times are GMT -4. The time now is 09:27 PM.


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