Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 07-31-2019, 04:37 PM   #1
EldonMcGuinness
Junior Member
EldonMcGuinness began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2019
Device: Kindle
Exclamation Using calibredb and fetch-ebook-metadata to fix invalidly identified books

I recently started using the WebUI to add books to my library via a web browser, it is just easier for some of my family members, but there is the occasional issue with a book being tagged wrong. I was hoping to fix this via command line, as I run Calibre on a headless server, using a combination of calibredb and fetch-ebook-metadata. I'll outline the script I put together below to fix it, which it does seem to do as far as calibredb returns, but the WebUI does not seem to reflect these changes. Am I missing something, is there another command that I should be running to get the library to realize there was an update?

Code:
#!/bin/bash

LIBPATH="$1"
BOOKID="$2"
AUTHOR="$3"
TITLE="$4"

fetch-ebook-metadata -t "$TITLE" -a "$AUTHOR" -o | tee temp.opf
calibredb --with-library "$LIBPATH" set_metadata $BOOKID temp.opf
calibredb embed_metadata $BOOKID --with-library "$LIBPATH"
rm temp.opf
Here is an example from calibredb of what a book was tagged incorrectly:
Code:
Title               : The Magic of Recluce
Title sort          : Magic of Recluce, The
Author(s)           : L. E. Modesitt, Jr. [L. E. Modesitt, Jr.]
Publisher           : Macmillan
Languages           : eng
Timestamp           : 2019-07-31T20:33:12+00:00
Published           : 2010-07-01T00:00:00+00:00
Identifiers         : sonybookid:CBUSCEHOL02U6Y0P
Formats             : EPUB
And here it is from calibredb after being fixed:
Code:
Title               : The Evertree
Title sort          : Evertree, The
Author(s)           : Marie Lu
Publisher           : Scholastic Australia
Tags                : Juvenile Fiction, Fantasy & Magic
Languages           : eng
Timestamp           : 2019-07-31T20:33:12+00:00
Published           : 2015-04-01T20:34:50+00:00
Identifiers         : google:2HmpBwAAQBAJ, isbn:9781925063776
Comments            : Everything comes to a head in this seventh book in the New York Times bestselling series. The world of Erdas will be changed forever.  Conor, Abeke, Meilin, and Rollan were once ordinary kids. Then they discovered that they had spirit animals-wise and powerful partners who granted them with amazing gifts … and a legendary responsibility. Together, the team has journeyed across Erdas, racing to stop a merciless foe. They have laughed and fought together. They've won challenges and lost friends. Some have even lost themselves.  Now that journey is about to end. They must reach a place forgotten by time and face off against an ancient enemy breaking free from his prison. They have just one chance to stop him … or the whole world will shatter.
Formats             : EPUB
EldonMcGuinness is offline   Reply With Quote
Old 07-31-2019, 09:17 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,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need to connect to the server using a server URL for --with-library are you doing that? And be running a version of calibre > 3
kovidgoyal is offline   Reply With Quote
Advert
Old 08-01-2019, 10:38 AM   #3
EldonMcGuinness
Junior Member
EldonMcGuinness began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2019
Device: Kindle
I'm actually on the server itself via SSH, the library variable is provided via the command line when I run the script, which is the actual path to the library directory itself, not the url for it. Is this not valid as it seems to work for updating the data in the DB.

The version of Calibre on the server is 3.46.0, I don't run Calibre locally as it would be redundant.

As an example to what I'm passing to the bash script, I've included the commands as they would be run.

Code:
updateBook /mnt/data/books 214 "Under Same Sky" "Cynthia DeFelice"
NOTE: `updateBook` is the name of the bash script that I included in the original post. The above command would run the following commands with the passed arguments being filled as outlined below.
Code:
fetch-ebook-metadata -t "Under Same Sky" -a "Cynthia DeFelice" -o | tee temp.opf
calibredb --with-library "/mnt/data/books" set_metadata 214 temp.opf
calibredb --with-library "/mnt/data/books" embed_metadata 214
As an update, I've found that restarting the calibre service seems to resolve the issue, so maybe it is some kind of caching on the server side?
EldonMcGuinness is offline   Reply With Quote
Old 08-01-2019, 11:01 AM   #4
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,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use the URL to the server, not the library path. See the details at https://manual.calibre-ebook.com/gen...calibredb.html
kovidgoyal is offline   Reply With Quote
Old 08-01-2019, 01:10 PM   #5
EldonMcGuinness
Junior Member
EldonMcGuinness began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2019
Device: Kindle
OK, figured out the issue and it seems to be a weird permissions issue I was having, where Calibre was creating a folder but the umask was too restrictive to allow the creation of files properly. No idea why it appeared to be fixed after a reboot, but added new umask to the service and it is all right as rain now.

As a side note, it works when you specify either the library location or the URL now.

Cheers for the help mate!
EldonMcGuinness is offline   Reply With Quote
Advert
Reply

Tags
calibredb calibre-server


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
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
calibredb add metadata issue vir_db Library Management 0 07-21-2014 07:12 AM
calibredb command line question (setting metadata) mezme Calibre 0 12-06-2011 12:17 AM
Can Excel SQL query get metadata out of calibredb? unboggling Calibre 24 01-20-2011 02:45 AM


All times are GMT -4. The time now is 01:12 PM.


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