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 04-12-2024, 04:03 PM   #1
KissMeKiwi
Junior Member
KissMeKiwi began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2023
Device: Kobo Clara 2E
Calibre Access in Python Script

Hi,

I am trying to create a request bot in Discord. I successfully created it with movies and tv shows, and am working on getting books working now.

I am confident I can get the book requests, but I also want an option for users to get a book sent to their email (mainly for Amazon's send to kindle).

My goal is:
  1. User performs a search for a book (or even an author)
  2. A list of books/authors is returned to the user
  3. User selects a book or author (if author, it then displays a list of books by the author)
  4. User selects a book
  5. Book is sent to their kindle email

What I am curious, is there an API or module to interact with calibre through python? Really I would need to look for a book, grab an epub (convert if it doesn't exist), and send it via an email. I saw some other links but it seemed like that was creating an entire environments for it and it got me confused.
KissMeKiwi is offline   Reply With Quote
Old 04-12-2024, 08:05 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,799
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Calibre has a powerful set of commandline tools.
Visit the online help: commandline tools for the gory details (no Pythons were harmed )
theducks is offline   Reply With Quote
Advert
Old 04-13-2024, 07:17 PM   #3
KissMeKiwi
Junior Member
KissMeKiwi began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2023
Device: Kobo Clara 2E
Quote:
Originally Posted by theducks View Post
Calibre has a powerful set of commandline tools.
Visit the online help: commandline tools for the gory details (no Pythons were harmed )
Okay so in theory, I can just run shell commands on the same machine which really should be doable in python.
KissMeKiwi is offline   Reply With Quote
Old 04-13-2024, 08:02 PM   #4
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by KissMeKiwi View Post
What I am curious, is there an API or module to interact with calibre through python? Really I would need to look for a book, grab an epub (convert if it doesn't exist), and send it via an email. I saw some other links but it seemed like that was creating an entire environments for it and it got me confused.
API documentation for the database interface: https://manual.calibre-ebook.com/en/db_api.html

API documentation for the e-book editing tools: https://manual.calibre-ebook.com/en/polish.html

You can use the API in your python scripts. To execute the script, you use this command:
calibre-debug /path/to/your/python/script.py

Quote:
Originally Posted by KissMeKiwi View Post
Okay so in theory, I can just run shell commands on the same machine which really should be doable in python.
Command Line Interface: https://manual.calibre-ebook.com/en/...cli-index.html
Yes, using the Command Line Interface.

Last edited by thiago.eec; 04-13-2024 at 08:07 PM.
thiago.eec is offline   Reply With Quote
Old 04-13-2024, 09:16 PM   #5
KissMeKiwi
Junior Member
KissMeKiwi began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2023
Device: Kobo Clara 2E
Quote:
Originally Posted by thiago.eec View Post
API documentation for the database interface: https://manual.calibre-ebook.com/en/db_api.html

API documentation for the e-book editing tools: https://manual.calibre-ebook.com/en/polish.html

You can use the API in your python scripts. To execute the script, you use this command:
calibre-debug /path/to/your/python/script.py


Command Line Interface: https://manual.calibre-ebook.com/en/...cli-index.html
Yes, using the Command Line Interface.
Thanks for showing me I have to use the calibre-debug, I saw that doc but was very confused. Is there anyway to access that api outside of the calibre-debug environment? I plan on running this in a container and it might be tough to get all the dependencies and get everything set up.
KissMeKiwi is offline   Reply With Quote
Advert
Old 04-14-2024, 05:42 AM   #6
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by KissMeKiwi View Post
Thanks for showing me I have to use the calibre-debug, I saw that doc but was very confused. Is there anyway to access that api outside of the calibre-debug environment? I plan on running this in a container and it might be tough to get all the dependencies and get everything set up.
There's no need to set up a development environment. 'calibre-debug.exe' is an executable that comes with calibre regular install. Just open your terminal and type the command I gave you.
thiago.eec is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run python script? UserError Kindle Developer's Corner 1 01-09-2024 03:31 PM
3.34 calibre-debug runs the script code under Python 3 EbokJunkie Conversion 2 11-20-2018 07:43 PM
how to use python script with windows xp tuufbiz1 Other formats 12 01-08-2011 08:22 AM
How do I get a shortcut for a Python script onto the taskbar in W7? Sydney's Mom Workshop 6 03-28-2010 08:11 PM
Nedd a little help with a python script gandor62 Calibre 1 08-07-2008 09:59 PM


All times are GMT -4. The time now is 01:53 AM.


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