2
0
mirror of https://github.com/koreader/koreader synced 2024-11-16 06:12:56 +00:00

[plugin] Display OPDS download titles if available (#8441)

I've found that some OPDS catalogs have multiple downloads of the same filetype, but optimized or formatted in different ways. The Title of the download is much more descriptive in this case, so I thought it would be better to display the title if available.

The OPDS catalog at https://standardebooks.org/opds is a good example. Note how entries in https://standardebooks.org/opds/new-releases have three different epub downloads, titled "Recommended compatible epub", "Advanced epub", and "Kobo Kepub epub".
This commit is contained in:
Dylan Garrett 2021-11-13 22:52:53 -08:00 committed by GitHub
parent 5709b4c2f1
commit 26ec5bafe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -496,6 +496,7 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url, username, passwo
table.insert(item.acquisitions, {
type = link.type,
href = build_href(link.href),
title = link.title,
})
elseif link.rel == self.thumbnail_rel then
item.thumbnail = build_href(link.href)
@ -702,7 +703,11 @@ function OPDSBrowser:showDownloads(item)
if filetype then
filetype = string.lower(filetype)
-- append DOWNWARDS BLACK ARROW ⬇ U+2B07 to format
button.text = string.upper(filetype) .. "\xE2\xAC\x87"
if acquisition.title then
button.text = acquisition.title .. "\xE2\xAC\x87"
else
button.text = string.upper(filetype) .. "\xE2\xAC\x87"
end
button.callback = function()
self:downloadFile(item, filetype, acquisition.href)
UIManager:close(self.download_dialog)

View File

@ -316,6 +316,7 @@ describe("OPDS module #nocov", function()
local entry = entries[2]
assert.are.same(entry.title, "1000 Mythological Characters Briefly Described")
assert.are.same(entry.link[1].href, "https://www.gutenberg.org/ebooks/42474.epub.images")
assert.are.same(entry.link[1].title, "EPUB (with images)")
end)
end)