Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Related Tools

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2015, 06:30 PM   #1
tigran
Zealot
tigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 140
Karma: 23528
Join Date: Nov 2009
Location: London
Device: Kobo Aura One,HD,H2O,Touch,Mini,Kindle 3+DXG,Nook Simple Touch
ebook-meta fails when used via Apache web server

When I execute ebook-meta on a mobi or epub files as a normal user it shows the metadata (and --get-cover extracts the cover) absolutely fine, but if I try to run it from within a PHP script (on Apache 2.4.10) it fails like this:

No cover found
Title : Unknown
Author(s) : Unknown

I.e. reports no cover and "Unknown" values for Title and Author. When executed as a normal user it shows not only the correct Title and Author but also Publisher, Languages, Published and Rights fields.

Any idea what may be wrong? I am using version 0.9.6. I didn't forget to set up the environment variables

export CALIBRE_CONFIG_DIRECTORY=/var/www/public_html/site/calibre
export CALIBRE_TEMP_DIR=/tmp

Should I set up something else as well? I am guessing that it is some kind of permission issue which makes it different when run as user daemon, group daemon...

I forgot to mention that I am running Fedora Core 17, which is why I didn't use the latest calibre (from source) --- its dependencies cannot be brought back to Fedora 17 (at least I couldn't, but maybe that was because I am not a python programmer, but a C programmer (Linux kernel developer)).

I did strace -o log of both invocations (via normal user and from PHP script) and see that the difference seems to be that immediately after opening the book in the failing case it does NOT even look for the file "/usr/lib64/calibre/calibre/ebooks/metadata/mobi.py" (and mobi.pyc) whereas in the working case it opens this file ok.

So, I need to find out what it is (some environment variable?) that controls whether to look for "mobi.py" or not.

Last edited by tigran; 01-23-2015 at 03:42 AM.
tigran is offline   Reply With Quote
Old 01-23-2015, 03:47 AM   #2
tigran
Zealot
tigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 140
Karma: 23528
Join Date: Nov 2009
Location: London
Device: Kobo Aura One,HD,H2O,Touch,Mini,Kindle 3+DXG,Nook Simple Touch
Ah, I think I have figured it out! The PHP temporary file has the form /tmp/phpblahblah whereas calibre assumes that the filename has the structure name.format so I guess I have to rename this temporary file to have .mobi extension for ebook-meta to work. I have reproduced the "everything=Unknown" problem by running ebook-meta on a file without .mobi extension, so I am pretty sure this is the cause of the problem. I'll try it in the real PHP scenario now...

UPDATE: Yes, it works now!

UPDATE: No, on some books it still breaks with this error:

No protocol specified
: cannot connect to X server :0

This is the case when it outputs (when executed as a normal user) the message "loaded the Generic plugin". So, this "Generic plugin" seems to be an X application and wants to connect to X server. Very strange... Any ideas? (I'll try setting DISPLAY but really this is wrong --- standalone text-based utilities are NOT supposed to require X to run).

UPDATE: the solution is to unset DISPLAY before executing ebook-meta.

All these tricks should really be documented somewhere...

Last edited by tigran; 01-23-2015 at 06:53 AM.
tigran is offline   Reply With Quote
Old 01-26-2015, 09:29 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You can use the latest version of calibre by installing the standalone binaries distributed on http://calibre-ebook.com/download_linux

All dependencies are bundled (except for the glibc requirement) and a side bonus is that you can be assured the distro isn't patching it and causing Problems.

calibre 2.x has lots of improvements for running the cli portions.
eschwartz is offline   Reply With Quote
Old 02-02-2015, 02:55 PM   #4
tigran
Zealot
tigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austentigran has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 140
Karma: 23528
Join Date: Nov 2009
Location: London
Device: Kobo Aura One,HD,H2O,Touch,Mini,Kindle 3+DXG,Nook Simple Touch
Thank you for the suggestion --- I followed it and I can confirm that, indeed, in the latest (2.18) version the command line utility ebook-meta no longer requires all that jiggery-pokery with the DISPLAY variable.
tigran is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP+Apache web server for calibre ... chaley Related Tools 254 04-28-2014 08:18 PM
calibre-server OPDS catalog - manual move to web server HaakonME Related Tools 5 09-21-2012 03:11 AM
Content Server with Apache Reverse Proxy Caleb666 Calibre 1 08-29-2011 04:20 PM
calibre, apache, mod_python content server rupa Calibre 0 12-26-2010 10:29 AM
set meta data with ebook-meta and ebook-convert krischik Calibre 6 01-19-2010 11:40 AM


All times are GMT -4. The time now is 04:14 PM.


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