Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-03-2025, 03:45 PM   #1
mitsie
Member
mitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 11
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
Smile Accessing filepath from Metadata Plugin

Does anybody know how to access the Filepath or even the BookID from within the Identify class as part of a metadata plugin?

I noticed the `calibre.utils.filename` but couldn't find a class to return the current path of the current book sent via the metadata thread.

Is there a quick way to get it? Or do I need to include the DB, run a search on the book title to get the book ID, and then do a search on the file paths?

Just wondered if there was an easy way to do this. My plugin is nearly complete.

Just need the file location for each metadata submission as the worker cycles through each title to finish it off.
mitsie is online now   Reply With Quote
Old 06-04-2025, 12:22 AM   #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,251
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
What metadata plugin? reader, writer, metadata source plugin?
kovidgoyal is offline   Reply With Quote
Old 06-04-2025, 04:20 AM   #3
mitsie
Member
mitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 11
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
Metadata source plugin, when the thread passes each book to the Identify function. It only seems to pass the title, author and identifiers. I was wondering if there is a helper function to retrieve the current ebook paths for the current title being identified?

Or would I have to do a DB search, something like:
SELECT * FROM books LEFT JOIN data ON books.id = data.book WHERE books.title LIKE "'+ title +'%" AND (data.format = "PDF" OR data.format = "EPUB")

so I could retrieve the PDF and EPUB paths for the current title?

Then, looking at the DB, it only has the path without the Calibre Library location, so I would have to write the path back together using something like:

book_path = book_path.replace('/', os.sep) + os.sep + book_title + "." + str(file_format).lower

But then, still, it would be missing the Calibre library location.

Just seems a bit long-winded if there were a helper function to retrieve this information, it would be perfect.

Last edited by mitsie; 06-04-2025 at 04:25 AM.
mitsie is online now   Reply With Quote
Old 06-04-2025, 10:18 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,251
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no such function and metadata source plugins can be used to download metadata completely separately from any calibre library, see the fetch-ebook-metadata command line tool, so you cant rely on accessing calibre library metadata in such a plugin either.
kovidgoyal is offline   Reply With Quote
Old 06-04-2025, 10:54 AM   #5
mitsie
Member
mitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 11
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
Yes, but I want to use the file itself to retrieve the metadata from the file, by passing it to a localhost server that will analyse and summarise the file and return the metadata.
To be in sync with what Calibre is doing and to have the context to return the exact data for the individual book and to put the returning metadata into the result_queue, I need to be able to retrieve the file location and send it to the localhost for analysis.

So what you are saying is I'm going to have to do a database search and then compile the paths from the DB result?

Just another quick question. For the Cache DB class, in the documentation, it doesn't say what any of the custom classes are expecting as input e.g.

search(query, restriction='', virtual_fields=None, book_ids=None)
Search the database for the specified query, returning a set of matched book ids.

Query in what way? an SQL query e.g. "SELECT book_id FROM books" ? a cut-down query "book_id From Books" a Set, a Dict, a list of tuples? Do we need to set a cursor and send that, like working with SQLite?

Without the input information, I'm trying to stack trace to find the original function to work out the inputs to the functions. Is it worth adding the expected input to the documentation? Plus, maybe a little example so people get the idea of how the custom function works?
mitsie is online now   Reply With Quote
Old 06-04-2025, 11:03 AM   #6
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,251
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Accessing book files from metadata plugins is *completely unsupported*. Your plugin is likely to break in all sots of unexpected ways. If you really want to fetch metadata based on book contents, then rather than writing a metadata source plugin write a user interface plugin, that can access the book files and do whatever it likes using the database APIs.
kovidgoyal is offline   Reply With Quote
Old 06-04-2025, 11:40 AM   #7
mitsie
Member
mitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentametermitsie can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 11
Karma: 12814
Join Date: Jun 2025
Device: PocketBook 4
I coded the plugin in Python, it worked brilliantly. And I wanted the ease of using the Metadata compare feature for the returned data from the plugin instead of having to reinvent the wheel.

If I hard-code the ebook paths and then reference the paths from within the plugin, everything works great. But as you can understand, hardcoding a list of paths isn't going to work lol.

Saying it's not supported is like a red rag to a bull. I'll make it work lol
The Metadata plugin can retrieve data from API's and websites. Thats its intended use.. So If the SQLite3 way doesn't work, I'll simply install Calibre Web and use the API to retrieve the download links (filepaths) that way as a web API call. Then use the links as a second call to my server running on localhost, which will retrieve the metadata and pass it back to Calibre. Where there is a will, there is a Way.
mitsie is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Metadata Reader Plugin] Read MP3 audio book metadata Jesse Chisholm Plugins 59 04-01-2025 10:16 AM
[Metadata Reader Plugin] Read M4B audio book metadata eliteart Plugins 5 01-01-2025 09:45 AM
[Metadata Source Plugin] Empty Plugin? (Fake Identifier) mneimeyer Plugins 3 11-11-2019 08:07 PM
Regarding using metadata objects in identify method of metadata download plugin api aprekates Development 1 07-06-2014 03:35 AM
weirdness while accessing metadata in plugin At_Libitum Development 7 10-22-2013 07:44 AM


All times are GMT -4. The time now is 07:32 PM.


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