[feat] Support mimetypes in DocumentRegistry:hasProvider()#7155
Merged
Frenzie merged 7 commits intokoreader:masterfrom Jan 17, 2021
Merged
[feat] Support mimetypes in DocumentRegistry:hasProvider()#7155Frenzie merged 7 commits intokoreader:masterfrom
Frenzie merged 7 commits intokoreader:masterfrom
Conversation
poire-z
reviewed
Jan 16, 2021
Contributor
poire-z
left a comment
There was a problem hiding this comment.
Nothing needed on the OPDS side ?
Member
Author
I found "can someone explain to me" a bit rude, so I wasn't feeling it tonight. But it'd look something like this: diff --git a/frontend/ui/widget/opdsbrowser.lua b/frontend/ui/widget/opdsbrowser.lua
index c8c0b4ca..cdceffde 100644
--- a/frontend/ui/widget/opdsbrowser.lua
+++ b/frontend/ui/widget/opdsbrowser.lua
@@ -4,6 +4,7 @@ local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
local Cache = require("cache")
local CacheItem = require("cacheitem")
local ConfirmBox = require("ui/widget/confirmbox")
+local DocumentRegistry = require("document/documentregistry")
local InfoMessage = require("ui/widget/infomessage")
local Menu = require("ui/widget/menu")
local MultiInputDialog = require("ui/widget/multiinputdialog")
@@ -45,27 +46,6 @@ local OPDSBrowser = Menu:extend{
image_rel = "http://opds-spec.org/image",
thumbnail_rel = "http://opds-spec.org/image/thumbnail",
- formats = {
- ["application/epub+zip"] = "EPUB",
- ["application/fb2+zip"] = "FB2",
- ["application/pdf"] = "PDF",
- ["text/html"] = "HTML",
- ["text/plain"] = "TXT",
- ["application/x-mobipocket-ebook"] = "MOBI",
- ["application/x-mobi8-ebook"] = "AZW3",
- ["application/vnd.amazon.mobi8-ebook"] = "AZW3",
- ["application/x-cbz"] = "CBZ",
- ["application/vnd.comicbook+zip"] = "CBZ",
- ["application/zip"] = "CBZ",
- ["application/x-cbr"] = "CBR",
- ["application/vnd.comicbook-rar"] = "CBR",
- ["application/x-rar-compressed"] = "CBR",
- ["application/vnd.rar"] = "CBR",
- ["application/djvu"] = "DJVU",
- ["image/x-djvu"] = "DJVU",
- ["image/vnd.djvu"] = "DJVU",
- },
-
width = Screen:getWidth(),
height = Screen:getHeight(),
no_title = false,
@@ -646,12 +626,17 @@ function OPDSBrowser:showDownloads(item)
local index = (i-1)*downloadsperline + j
local acquisition = acquisitions[index]
if acquisition then
- local format = self.formats[acquisition.type]
- if format then
+ local filetype
+ if DocumentRegistry:hasProvider(nil, acquisition.type) then
+ filetype = DocumentRegistry:mimeToExt(acquisition.type)
+ elseif DocumentRegistry:hasProvider(acquisition.href) then
+ filetype = string.upper(util.getFileNameSuffix(acquisition.href))
+ end
+ if filetype then
-- append DOWNWARDS BLACK ARROW ⬇ U+2B07 to format
- button.text = format .. "\xE2\xAC\x87"
+ button.text = filetype .. "\xE2\xAC\x87"
button.callback = function()
- self:downloadFile(item, format, acquisition.href)
+ self:downloadFile(item, filetype, acquisition.href)
UIManager:close(self.download_dialog)
end
table.insert(line, button) |
Frenzie
commented
Jan 16, 2021
poire-z
approved these changes
Jan 17, 2021
wasn't meant to be rude, sorry. |
Member
Author
|
Alright, no problem. A file as described in #6585 (comment) should now work with the fallback, but I've only been able to test it for Wallabag. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5478.
This change is