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 09-26-2018, 12:38 PM   #1
Nriver
Junior Member
Nriver began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2018
Device: kindle3
Lightbulb Add a book to calibre with python

Hi, I am trying to add my ebook to calibre content server by sending post request with python. And here is the code.
https://gist.github.com/Nriver/7b62d...97d16226d3da3a

This worked and calibre server did get the new book. However, when I compare the ebook file in the calibre server and the original one, I found the file content is little bit wrong. The form information was on the top of the file. Please see the attachment image.

If I upload it with Chrome manually, this won't happen. I am wondering whether there is something wrong with my code.

I had read some of the calibre source code.
In the cdb.py file, there is a line 'rd.request_body_file.seek(0)', could this be cause of the problem? Maybe the real file content should start with some offset?

P.S.
'ctx' stands for context, and what is 'rd' stand for? I see them a lot in the server code.
Attached Thumbnails
Click image for larger version

Name:	extra header.jpg
Views:	313
Size:	119.9 KB
ID:	166501  
Nriver is offline   Reply With Quote
Old 09-27-2018, 12:25 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,260
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Why not just use calibredb.exe, it can connect to a calibre server and add books, set metadata and do lots of other operations.

rd stands for RequestData
kovidgoyal is offline   Reply With Quote
Advert
Old 09-27-2018, 06:12 AM   #3
Nriver
Junior Member
Nriver began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Sep 2018
Device: kindle3
I am writing a crawler to generate ebook on a different server. So I think it would be better if I can add the book over the content server.
Nriver is offline   Reply With Quote
Old 09-27-2018, 11:27 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,260
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah calibredb allows you to add the book over the server, it acts as a client connecting to the server.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get book cover width and height in Calibre Python code? datcha Library Management 3 02-11-2016 09:55 AM
How To Add OPF Book To Calibre? Vienna01 Calibre 7 08-28-2015 10:28 AM
Python script to add scribble to pdf - teach me how to make into a plugin cadmus Plugins 2 02-21-2012 02:03 PM
Cannot add a book to Calibre daithi81 Calibre 20 01-30-2010 10:01 PM


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


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