mikespub-org / seblucas-cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
55 stars 7 forks source link

OPDS error with Moon+ Reader: No Protocol #66

Closed SenorSmartyPants closed 7 months ago

SenorSmartyPants commented 8 months ago

I have a OPDS entry for COPS that was working fine before I switched over to your updated source (Thanks for taking this on). Now I can browse the top level fine, but when I tap Authors I get Error no protocol: /feed.php?page=1.

I assume Moon+ Reader 8.1 on Android must need a full url and has problems with relative URLs. Link images don't show up either.

I'm running v2.1.5 LSIO docker

dunxd commented 8 months ago

I don't see this with Moon+ Reader 8.4 on Android. Authors gives me the alphabetical folders, and I can browse deeper no problem.

SenorSmartyPants commented 8 months ago

Just tried it on my phone with M+R 8.4 and Android 10. Same error.

First report was on an Amazon Fire HD 8

dunxd commented 8 months ago

Is your COPS instance hosted in a folder? e.g. server.example.com/a-folder/feed.php

mikespub commented 8 months ago

Not sure why the old "feed.php" would be acceptable without protocol and the new "/feed.php" would not for this version of Moon+ Reader, but you may need to set the full url prefix in your local config:

/*
 * Full URL prefix (with trailing /)
 * useful especially for Opensearch where a full URL is often required
 * For example Mantano, Aldiko and Marvin require it.
 */
//$config['cops_full_url'] = '';
$config['cops_full_url'] = 'http://localhost/cops/';
dunxd commented 8 months ago

Given that /feed.php is working fine with my installation and Moon+ Reader, and I have not changed config['cops_full_url'] from the default of empty, I wonder if there is something specific about @SenorSmartyPants installation causing the issue.

I have checked with the current main commit on my dev container, and with 2.1.5 on my production system and Moon+ Reader works fine as far as I have tested.

dunxd commented 8 months ago

Also checked with linuxserver/cops image and it is working fine with Moon+ Reader for me. Can navigate through Authors, Series, Publishers, Tags, Ratings, Languages, All Books, Recent Books.

The one thing I did notice just now in Moon+ Reader that navigating to Publishers, then going into a publisher's books, then clicking the back button twice throws an error No more occurrences found. This does not happen if I go to Publishers then click on the back button - only after I have gone one level in. It doesn't happen with any other category, but every time with Publishers. This doesn't occur in Librera.

mikespub commented 8 months ago

Thanks for checking @dunxd - it seems like every e-book reader app has its own issues...

Anyway, coming back to @SenorSmartyPants I agree it's probably easiest to solve if we know what the full url is supposed to look like from the app's perspective, and that will depend on the actual installation/setup

SenorSmartyPants commented 8 months ago

Sometimes the error is Unable to resolve host "feed.php": No address associated with hostname

Is your COPS instance hosted in a folder? e.g. server.example.com/a-folder/feed.php

No

Have either of you tried with a port number in your url?

I access my cops server locally at http://rockpi:9090 . OPDS feeds in M+R are pointing to http://rockpi:9090/feed.php

Setting config['cops_full_url'] works in client. But I'm also trying to set up external SSL access (NGINX proxy) and the URL would be different for that so this is not a long term solution. Unless you build the full url dynamically based on requesting url.

I'm beginning to feel this could be more of a M+R error. I'm going to email seanyword@gmail.com the M+R dev (only support contact I can find) and see if maybe they have some feedback.

Here is my docker-compose:

  cops:
    image: lscr.io/linuxserver/cops
    container_name: cops
    environment:
      - TZ=${TZ}
      - PUID=${PUID}
      - PGID=100
    volumes:
      - /mnt/seagate4TB/appdata/cops:/config
      - /mnt/storage/media/Books:/books
    ports:
      - 9090:80
    restart: unless-stopped

Here's my feed.php output

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:thr="http://purl.org/syndication/thread/1.0">
<title>Books</title>
<subtitle>Books for Nerds</subtitle>
<id>cops:catalog</id>
<updated>2023-10-15T19:18:18+00:00</updated>
<icon>favicon.ico</icon>
<author>
<name>Sébastien Lucas</name>
<uri>http://blog.slucas.fr</uri>
<email>sebastien@slucas.fr</email>
</author>
<link href="/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="start" title="Home"/>
<link href="/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="self"/>
<link href="/feed.php?page=8" type="application/opensearchdescription+xml" rel="search" title="Search here"/>
<entry>
<title>Authors</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:authors</id>
<content type="text">Alphabetical index of the 116 authors</content>
<link href="/feed.php?page=1" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="116"/>
<link href="/images/author.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Series</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:series</id>
<content type="text">Alphabetical index of the 56 series</content>
<link href="/feed.php?page=6" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="56"/>
<link href="/images/serie.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Publishers</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:publishers</id>
<content type="text">Alphabetical index of the 77 publishers</content>
<link href="/feed.php?page=20" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="77"/>
<link href="/images/publisher.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Tags</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:tags</id>
<content type="text">Alphabetical index of the 90 tags</content>
<link href="/feed.php?page=11" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="90"/>
<link href="/images/tag.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>All books</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:books</id>
<content type="text">Alphabetical index of the 331 books</content>
<link href="/feed.php?page=4" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="331"/>
<link href="/images/allbook.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Recent additions</title>
<updated>2023-10-15T19:18:18+00:00</updated>
<id>cops:recentbooks</id>
<content type="text">50 most recent books</content>
<link href="/feed.php?page=10" type="application/atom+xml;profile=opds-catalog;kind=acquisition" rel="http://opds-spec.org/sort/new" thr:count="50"/>
<link href="/images/recent.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
</feed>

Here's my feed.php with config['cops_full_url'] set. This works in client.

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:thr="http://purl.org/syndication/thread/1.0">
<title>Books</title>
<subtitle>Books for Nerds</subtitle>
<id>cops:catalog</id>
<updated>2023-10-15T19:21:15+00:00</updated>
<icon>favicon.ico</icon>
<author>
<name>Sébastien Lucas</name>
<uri>http://blog.slucas.fr</uri>
<email>sebastien@slucas.fr</email>
</author>
<link href="http://rockpi:9090/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="start" title="Home"/>
<link href="http://rockpi:9090/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="self"/>
<link href="http://rockpi:9090/feed.php?page=8" type="application/opensearchdescription+xml" rel="search" title="Search here"/>
<entry>
<title>Authors</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:authors</id>
<content type="text">Alphabetical index of the 116 authors</content>
<link href="http://rockpi:9090/feed.php?page=1" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="116"/>
<link href="http://rockpi:9090/images/author.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Series</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:series</id>
<content type="text">Alphabetical index of the 56 series</content>
<link href="http://rockpi:9090/feed.php?page=6" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="56"/>
<link href="http://rockpi:9090/images/serie.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Publishers</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:publishers</id>
<content type="text">Alphabetical index of the 77 publishers</content>
<link href="http://rockpi:9090/feed.php?page=20" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="77"/>
<link href="http://rockpi:9090/images/publisher.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Tags</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:tags</id>
<content type="text">Alphabetical index of the 90 tags</content>
<link href="http://rockpi:9090/feed.php?page=11" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="90"/>
<link href="http://rockpi:9090/images/tag.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>All books</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:books</id>
<content type="text">Alphabetical index of the 331 books</content>
<link href="http://rockpi:9090/feed.php?page=4" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="331"/>
<link href="http://rockpi:9090/images/allbook.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Recent additions</title>
<updated>2023-10-15T19:21:15+00:00</updated>
<id>cops:recentbooks</id>
<content type="text">50 most recent books</content>
<link href="http://rockpi:9090/feed.php?page=10" type="application/atom+xml;profile=opds-catalog;kind=acquisition" rel="http://opds-spec.org/sort/new" thr:count="50"/>
<link href="http://rockpi:9090/images/recent.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
</feed>
mikespub commented 8 months ago

Glad to hear the full_url option works for you, at least for now. That means for some reason M+ R accepts "feed.php" and "http://rockpi:9090/feed.php" but not "/feed.php" - hopefully they can clear up why...

For later, if you want to make $config['cops_full_url'] configurable based on the requesting URL, you could probably put that in your config_local.php file so that it applies for every route in COPS (web or OPDS) for your setup.

_Note: in theory we could also put some custom logic inside Route::base() https://github.com/mikespub-org/seblucas-cops/blob/eacb560f4f01343176c46515211359dfe5931512/lib/Input/Route.php#L315 but there are so many options to cover every potential use case that it quickly becomes un-manageable - that's why I kept it simple. So the rule now is: if you want something special, adapt your $config['cops_full_url'] :-)_

dunxd commented 8 months ago

I just can't replicate the issue - I am running the linuxserver/cops container. It is hosted at http://ip_address:8080 and the links all start with /feed.php - Moon+ Reader 8.4 on Android 13 working fine - displaying all images and can navigate apart from that odd issue with Publishers and the back button.

Here is my OPDS:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:opds="http://opds-spec.org/2010/catalog" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:thr="http://purl.org/syndication/thread/1.0">
<title>COPS</title>
<id>cops:catalog</id>
<updated>2023-10-17T08:40:54+00:00</updated>
<icon>favicon.ico</icon>
<author>
<name>Sébastien Lucas</name>
<uri>http://blog.slucas.fr</uri>
<email>sebastien@slucas.fr</email>
</author>
<link href="/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="start" title="Home"/>
<link href="/feed.php" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="self"/>
<link href="/feed.php?page=8" type="application/opensearchdescription+xml" rel="search" title="Search here"/>
<entry>
<title>Authors</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:authors</id>
<content type="text">Alphabetical index of the 253 authors</content>
<link href="/feed.php?page=1" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="253"/>
<link href="/images/author.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Series</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:series</id>
<content type="text">Alphabetical index of the 35 series</content>
<link href="/feed.php?page=6" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="35"/>
<link href="/images/serie.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Publishers</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:publishers</id>
<content type="text">Alphabetical index of the 136 publishers</content>
<link href="/feed.php?page=20" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="136"/>
<link href="/images/publisher.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Tags</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:tags</id>
<content type="text">Alphabetical index of the 38 tags</content>
<link href="/feed.php?page=11" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="38"/>
<link href="/images/tag.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Ratings</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:rating</id>
<content type="text">5 ratings</content>
<link href="/feed.php?page=22" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="5"/>
<link href="/images/rating.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Languages</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:languages</id>
<content type="text">Alphabetical index of the single language</content>
<link href="/feed.php?page=17" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="1"/>
<link href="/images/language.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>All books</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:books</id>
<content type="text">Alphabetical index of the 352 books</content>
<link href="/feed.php?page=4" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection" thr:count="352"/>
<link href="/images/allbook.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
<entry>
<title>Recent additions</title>
<updated>2023-10-17T08:40:54+00:00</updated>
<id>cops:recentbooks</id>
<content type="text">50 most recent books</content>
<link href="/feed.php?page=10" type="application/atom+xml;profile=opds-catalog;kind=acquisition" rel="http://opds-spec.org/sort/new" thr:count="50"/>
<link href="/images/recent.png?v=2.1.5" type="image/png" rel="http://opds-spec.org/image/thumbnail"/>
</entry>
</feed>

I really can't think why your install doesn't work when mine does, and then starts working when you set config['cops_full_url']. I'm not dismissing what you see - it must be something really odd. Could there be any issue with local caching? Have you tried a full reinstall of Moon+ Reader in case something is being cached in Android or the app itself?

quorn23 commented 8 months ago

set the full url prefix in your local config:

/*
 * Full URL prefix (with trailing /)
 * useful especially for Opensearch where a full URL is often required
 * For example Mantano, Aldiko and Marvin require it.
 */
//$config['cops_full_url'] = '';
$config['cops_full_url'] = 'http://localhost/cops/';

I don't see that comment at all in my config_local.php. I don't see it in the config_local.php.example on this repo either. Did you gave a full example including comment, or am i looking at the wrong place? :D

Can confirm the initial reported issue. Using latest LSIO Image and latest MoonReader Pro (8.5). I cleared the storage on my phone, i removed the container and it's config and let it generate a fresh config, the error changed from the initial one to "No more occurrences found" when i want to travel deeper from the overview. I send the Moonreader dev an email, cops itself works fine via web.

mikespub commented 8 months ago

There are many configuration options available in COPS, as seblucas et al. added tweaks and changes over the years...

So you will find the following notice at the top of config_local.php.example:

/*
 ***************************************************
 * Please read config_default.php for all possible
 * configuration items
 * For changes in config_default.php see CHANGELOG.md
 ***************************************************
 */

Perhaps we could include cops_full_url in the example by default to make it easier to find?

Regarding future (lack of) support for http, this isn't the first project I've heard consider it to improve security by design, but it does make things awkward for local installations...

dunxd commented 8 months ago

@quorn23 thanks for sharing that you are also seeing the issue. I had managed to get the No more occurrences found when navigating back from the list of Publishers but nowhere else.

Are you getting this when you navigate within Moon+ Reader from the home/landing page when you navigate deeper into Authors etc.?

Does adding the $config['cops_full_url'] = line to config_local.php fix the issue for you?

It would be interesting to hear back from Moon+ Reader developers what triggers the error messages you and @SenorSmartyPants have reported.

As an aside, it is worthwhile reading config_default.php to see all the options you can override in config_local.php - config_example.php only shows the most commonly needed ones to get things up and running.

dunxd commented 7 months ago

@quorn23 @SenorSmartyPants did you ever hear anything back from the Moon+ Reader developers?

quorn23 commented 7 months ago

@quorn23 @SenorSmartyPants did you ever hear anything back from the Moon+ Reader developers?

Sadly not, no reaction. I added it to my reverse proxy in the mean time. I just noticed they released 8.5 a couple days ago, i'll see that i expose the port again and give it a test run the next few days.

SenorSmartyPants commented 7 months ago

@quorn23 @SenorSmartyPants did you ever hear anything back from the Moon+ Reader developers?

This is the response I got last month.

Hi, we're not sure what causes the problem temporarily, if this OPDS server can be accessed on the Internet, please send us its URL for testing.

and please note, in the next version, our reader will only support https OPDS server to fit Google's new security strategy.

Thank you! Regards Seany

mikespub commented 7 months ago

That still doesn't explain the difference, but their answer about "only support https" is in line with the initial error message "no protocol" you got, meaning at some point they're parsing and checking the URL.

Perhaps that version handled relative uri's "feed.php" differently than absolute uri's "/feed.php", but both would work when you specify the full url prefix in config_local.php.

Note: this isn't the first time I heard a client would restrict access to https only in the future - too bad this could make default installation of (possibly) local apps like COPS a bit more difficult...

SenorSmartyPants commented 7 months ago

Re: HTTPS only, I'd rather they make it the default with an option to turn it off, or support self signed certificates.

mikespub commented 7 months ago

With the $config['cops_full_url'] = line I'm marking this issue as resolved for now...