mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01: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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user