View Single Post
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:	318
Size:	119.9 KB
ID:	166501  
Nriver is offline   Reply With Quote