From 26ec5bafe30f406906fe1981d372b51da3db5b39 Mon Sep 17 00:00:00 2001 From: Dylan Garrett Date: Sat, 13 Nov 2021 22:52:53 -0800 Subject: [PATCH] [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". --- plugins/opds.koplugin/opdsbrowser.lua | 7 ++++++- spec/unit/opds_spec.lua | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/opds.koplugin/opdsbrowser.lua b/plugins/opds.koplugin/opdsbrowser.lua index 8e1f84b57..fc737e4f7 100644 --- a/plugins/opds.koplugin/opdsbrowser.lua +++ b/plugins/opds.koplugin/opdsbrowser.lua @@ -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) diff --git a/spec/unit/opds_spec.lua b/spec/unit/opds_spec.lua index 35a8abe69..a68246c27 100644 --- a/spec/unit/opds_spec.lua +++ b/spec/unit/opds_spec.lua @@ -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)