edrlab / thorium-reader

A cross platform desktop reading app, based on the Readium Desktop toolkit
https://www.edrlab.org/software/thorium-reader/
BSD 3-Clause "New" or "Revised" License
1.81k stars 154 forks source link

Incorrect interpretation of the OPDS 2 indirect acquisition feature. #2208

Closed llemeurfr closed 4 months ago

llemeurfr commented 5 months ago

The way Thorium is programmed, the behavior of acquisition links is constrained by the content type of the link target: in https://github.com/edrlab/thorium-reader/blob/dbfc221cdbdcddfb86d2ba425367e444f637c6d9/src/main/converter/opds.ts#L326 we see that a link of type acquisition or acquisition/open-access is active only if the content type is one of those listed in https://github.com/edrlab/thorium-reader/blob/dbfc221cdbdcddfb86d2ba425367e444f637c6d9/src/main/converter/opds.ts#L44

HTML is not one of them.

This constraint does not exist for links of type acquisition/buy or acquisition/subscribe. And the label of the button is associated with the acquisition type (acquisition/buy => "Buy this book").

Now here is the issue: A bookseller provides a subscription based service. He wants to provide an ODPS catalog to his users, but he cannot provide OPDS Authentication at this time. The solution I proposed is to generate an OPDS catalog with links to individual pages of his Web site, where users can authenticate, download an LCP license and side-load the license into Thorium Reader.

The feed should be like

"publications": [
    {
      "metadata": {
        "@type": "http://schema.org/Book",
        "title": "xxxx",
        "author": "xxxx",
        "identifier": "urn:isbn:xxxx",
        "language": "en"
      },
      "links": [
        {
          "rel": "http://opds-spec.org/acquisition",
          "href": "//link to the web page corresponding to the book//",
          "type": "text/html"
        }
      ],
      "images": [
        {
          "href": "https://edrlab.org/public/feed/moby-dick/cover.jpg",
          "type": "image/jpeg",
          "height": 499,
          "width": 348
        }
      ]
    }
]

But the rel = acquisition does not give what is expected, the button does not appear. I must use rel = acquisition/buy, but the label of the button is not what I expect.

I would like this use-case to be supported and every type of acquisition link be compatible with an html page as a target. The label could be "Import (Web)" if the acquisition link is of type acquisition.

I also see a bug with acquisition/borrow, whatever content type I use: I get a blank page and I must quit Thorium. You can test with this test OPDS feed -> https://edrlab.org/public/feed/test/opds-feed.json

panaC commented 4 months ago

I also see a bug with acquisition/borrow, whatever content type I use: I get a blank page and I must quit Thorium. You can test with this test OPDS feed -> https://edrlab.org/public/feed/test/opds-feed.json

You need to be authenticated to borrow a book, and your feed do not provide opdsAuthentication mechanism.

danielweck commented 4 months ago

isn't that the whole point of linking to an external website? it's like the CanTookStation test / demo feed, publications borrow/return actions can all be done from within Thorium (authenticated) or via the website (also auth). What Laurent is suggesting is that the LCP licenses would need manual download from website + import in Thorium, I think

panaC commented 4 months ago

I found the bug ! missing strictNullCheck on ln.properties

What Laurent is suggesting is that the LCP licenses would need manual download from website + import in Thorium, I think

Exactly and it works well, sorry for the misunderstanding.

panaC commented 4 months ago

Fixed by https://github.com/edrlab/thorium-reader/commit/7f4373c3f6ab73251b413bb5831988bbe5cef62b