Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 11-02-2022, 09:47 AM   #1
billalive
Junior Member
billalive began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2022
Device: none
Question How to Run Any (Non-GUI) Plugin From the Command Line?

Hi! First off, thank you for all your work on Calibre, and for making it open-source. A truly fantastic tool.

Is it possible to run all or most plugins from the command line?

For instance, I would like to export my BibTeX catalog from the command line.

That plugin code seems to live here:

https://github.com/kovidgoyal/calibr...logs/bibtex.py

So I thought I might do something like:

Code:
calibre-debug /usr/lib/calibre/calibre/library/catalogs/bibtex.py -- --verbose --citation-template "{author}-{title}-{pubdate}"
However, nothing happens.

I suspect that I need to execute the actual run() function in this plugin, and this would probably be a fairly trivial Python script.

But is there already an idiom for running a Calibre plugin like this from the command line?

Thank you!
billalive is offline   Reply With Quote
Old 11-02-2022, 10:41 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,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibredb catalog -h
kovidgoyal is offline   Reply With Quote
Old 11-02-2022, 12:10 PM   #3
billalive
Junior Member
billalive began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2022
Device: none
Excellent! Thank you for such a quick reply.

This command definitely meets my specific need. I can generate a BibTeX catalog with:

Code:
calibredb catalog calibre.bib --with-library ~/Calibre/ --entry-type=mixed --citation-template="{author_sort}-{title}-{pubdate}" --sort-by=author_sort
And there are more options for bibtex files:

Code:
calibredb catalog calibre.bib -h
So that is great.

For other plugins, does this mean that there is no general way to run any non-GUI plugin from the command line? Again, I'm sure it is doable with a short Python script that loads the module and uses the run() function. But I wanted to check first to see if there is already a command for this.

Thank you!
billalive is offline   Reply With Quote
Old 11-02-2022, 12:27 PM   #4
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Calibre does provide GUI plugins with an API to run in command line mode. For plugins that implements such and API users are supposed to invoke it with the command:

Code:
calibre-debug -r "Plugin Name"
However, I do not know of a single GUI plugin that actually implement this. So, the only way for you is to prey open the code, and figure out how to wrap the functionality in a script that runs from the command line.
capink is offline   Reply With Quote
Old 11-02-2022, 01:10 PM   #5
billalive
Junior Member
billalive began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2022
Device: none
Thanks, @capink! I believe that "calibre-debug -r" is exactly what I was looking for.

My main concern is being able to run non GUI plugins, so this command should be perfect. "calibre-debug -h" had all the details; I should have looked more carefully:

Quote:
-r RUN_PLUGIN, --run-plugin=RUN_PLUGIN
Run a plugin that provides a command line interface.
For example:
calibre-debug -r "Plugin name" -- file1 --option1
Everything after the -- will be passed to the plugin
as arguments.
Thanks again!
billalive is offline   Reply With Quote
Old 11-02-2022, 10:48 PM   #6
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Quote:
Originally Posted by capink View Post
Calibre does provide GUI plugins with an API to run in command line mode. For plugins that implements such and API users are supposed to invoke it with the command:

Code:
calibre-debug -r "Plugin Name"
However, I do not know of a single GUI plugin that actually implement this. So, the only way for you is to prey open the code, and figure out how to wrap the functionality in a script that runs from the command line.

Actually, the CalibreSpy GUI plugin is supposed to be normally run from the command line so multiple Libraries can be viewed simultaneously without the Calibre GUI being executed at all.


DaltonST
DaltonST is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GUI works, command line fails endo32 Conversion 1 06-17-2017 10:05 PM
search question gui vs command line keyser666 Calibre 1 04-21-2017 11:20 AM
Problem converting with GUI vs command line kelemvor Conversion 13 04-07-2016 04:04 PM
command line vs gui db update discrepancy -maybe? riksaga Calibre 1 03-21-2013 11:22 PM
command line vs GUI (PDF->MOBI for K2) tlc Calibre 12 02-24-2009 06:20 PM


All times are GMT -4. The time now is 02:37 PM.


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