Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre Companion

Notices

Reply
 
Thread Tools Search this Thread
Old 10-06-2016, 08:50 PM   #1
duckpuppy
Junior Member
duckpuppy began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Feb 2011
Device: Android, various
Lightbulb Calibre companion, calibre-server, and url-prefix: A question for the dev

I know that using url-prefix for calibre-server causes problems with using the content server connection in Calibre companion, and the solution at the moment is to enter the full URL to the content server with url-prefix. That works.

The Calibre content server home page has a "Feed" element with the actual URL of the opds feed, with url-prefix, and that hasn't changed in a while. A little bit of xpath magic on the returned HTML from the root path would get that URL. I haven't looked for xpath libraries for android, so maybe scraping the page is harder than it looks.

It could fall back to the current behavior of assuming no url-prefix if the xpath lookup/scraping fails, and there's no harm, no foul.

Is this a potential solution to make the discovery more automatic? Is it more trouble than it's worth?

UPDATE: A working (but simple) xpath expression to get the opds URL (or at least the path portion) is "//a[contains(@href, 'opds')]/@href"

This returns "/calibre/opds" on the HTML from my calibre server.

Last edited by duckpuppy; 10-06-2016 at 09:06 PM. Reason: Added xpath example
duckpuppy is offline   Reply With Quote
Old 10-07-2016, 04:10 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I am confused about what problem you are solving. If calibre has a url prefix set then one must use that prefix to reach calibre's home page. CC would need to know that prefix in order to open the home page. One CC has the home page then job done because the OPDS feed is always url-with-prefix/opds. No scraping is required.

What am I missing?
chaley is offline   Reply With Quote
Advert
Old 10-07-2016, 08:00 AM   #3
duckpuppy
Junior Member
duckpuppy began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Feb 2011
Device: Android, various
Not so - the root URL still works, even with the url-prefix set. I can go to "http://<my-ip>:8080" and see the main home page. All the links on the page link to "http://<my-ip>:8080/calibre/<subpage>". I can also get the homepage at "http://<my-ip>:8080/calibre", and that's in fact what the "Home" link on the main page links to.

This hasn't been an issue for me since I started using Calibre Companion early on - once wireless device connection was available, that's all I used (along with the reading list plugin and some custom tags to auto-sync on connection).

Others in my household are now using calibre, and they're not using a wireless device connection - that would mean leaving calibre running and giving them access to my PC. I have calibre-server running on a small PC with a copy of my library for them to access. That's how I ran into this - I was configuring several devices and noticed that it could connect without the "/calibre" and even authenticate, it just obviously couldn't get the opds catalog at "/opds". Then I used curl to grab the root page ("curl --digest -u <username> http://<my-ip>:8080") and got the full HTML for the home page.

Since that works, there's the possibility of auto-configuring CC even with a url-prefix by grabbing the proper opds URL at runtime.

Last edited by duckpuppy; 10-07-2016 at 08:10 AM.
duckpuppy is offline   Reply With Quote
Old 10-07-2016, 08:08 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by duckpuppy View Post
Not so - the root URL still works, even with the url-prefix set. I can go to "http://<my-ip>:8080" and see the main home page. All the links on the page link to "http://<my-ip>:8080/calibre/<subpage>". I can also get the homepage at "http://<my-ip>:8080/calibre", and that's in fact what the "Home" link on the main page links to.
Well, it doesn't work for me. I run calibre behind apache in reverse proxy mode, which means that calibre doesn't see anything if the url doesn't have the prefix. The IP address gets the main page for the virtual host. Supporting reverse proxy is why the url-prefix was added.

Why are you using a url-prefix when calibre is listening directly to the IP address?

In any event, supporting the use case of calibre directly listening to an IP but having a url-prefix isn't worth it for me. I suspect that you might be the only CC user who would use it.
chaley is offline   Reply With Quote
Old 10-10-2016, 09:05 AM   #5
duckpuppy
Junior Member
duckpuppy began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Feb 2011
Device: Android, various
Quote:
Originally Posted by chaley View Post
Well, it doesn't work for me. I run calibre behind apache in reverse proxy mode, which means that calibre doesn't see anything if the url doesn't have the prefix. The IP address gets the main page for the virtual host. Supporting reverse proxy is why the url-prefix was added.

Why are you using a url-prefix when calibre is listening directly to the IP address?

In any event, supporting the use case of calibre directly listening to an IP but having a url-prefix isn't worth it for me. I suspect that you might be the only CC user who would use it.
Calibre is always listening directly on an IP, otherwise there's nothing to proxy - the reverse proxy is typically for use from outside the network, which is why I have a url-prefix... for the reverse proxy connection. When I talk about using curl in my post above, I'm hitting the internal IP of calibre-server directly, avoiding the (in my case) nginx server acting as the proxy. I'm talking about autodiscovery, which implies using it inside my own network. Calibre-companion even takes that distinction into account with the ability to have separate configuration for "external" and "internal" connections. Auto discovery only typically works internally anyway.

I'm making a suggestion for a feature improvement that currently has a potentially very confusing failure mode to people who are technical enough to follow directions on a message board, but not technical enough to adequately troubleshoot problems (apparent success, including authentication, then simply having no book list), which I would assume actually encompasses a large number of CC users. It became annoying as a user when I made the same custom configs on 5 different devices, and I wondered if I could automate it - probably a side effect of my day job as an tooling and automation developer. Once something has been done two or three times, it's time to find or write a tool to stop having to do it yourself.

At the very least, CC should probably pop up an error dialog if the "/opds" link is not available, which would gently nudge users in the correct direction. It would also give an easily searchable consistent message in the form of the error text.

This would be more properly placed as an improvement or enhancement request in a bug tracker. I don't see that CC has one of those, so I put it here.

Last edited by duckpuppy; 10-10-2016 at 09:20 AM.
duckpuppy is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Cloud Service with Calibre Companion vs a Local Calibre Server varaonaid Calibre Companion 26 04-10-2016 01:55 AM
Do I need to run Calibre content server to use Calibre Companion flyash Calibre 2 04-06-2013 10:19 PM
Calibre GUI content server url-prefix ilovejedd Calibre 5 02-07-2012 11:07 PM
Content Server url prefix not working Caleb666 Calibre 3 09-04-2011 11:43 AM
Content Server --url-prefix danorum Calibre 8 12-12-2010 12:02 AM


All times are GMT -4. The time now is 04:28 AM.


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