Opds-pse v1.2 [LastRead], add resume from page button (#13357)
Some checks failed
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Has been cancelled
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Has been cancelled

This commit is contained in:
ShowY
2025-03-06 01:01:20 +05:30
committed by GitHub
parent 23ed86a0f8
commit 70d13be32a
2 changed files with 39 additions and 18 deletions

View File

@@ -418,11 +418,12 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url)
-- https://vaemendis.net/opds-pse/
-- «count» MUST provide the number of pages of the document
-- namespace may be not "pse"
local count
local count, last_read
for k, v in pairs(link) do
if k:sub(-6) == ":count" then
count = tonumber(v)
break
elseif k:sub(-9) == ":lastRead" then
last_read = tonumber(v)
end
end
if count then
@@ -431,6 +432,7 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url)
href = link_href,
title = link.title,
count = count,
last_read = last_read and last_read > 0 and last_read or nil
})
end
elseif link.rel == self.thumbnail_rel or link.rel == self.thumbnail_rel_alt then
@@ -584,22 +586,37 @@ function OPDSBrowser:showDownloads(item)
if acquisition.count then
stream_buttons = {
{
-- @translators "Stream" here refers to being able to read documents from an OPDS server without downloading them completely, on a page by page basis.
text = _("Page stream") .. "\u{2B0C}", -- append LEFT RIGHT BLACK ARROW
callback = function()
OPDSPSE:streamPages(acquisition.href, acquisition.count, false, self.root_catalog_username, self.root_catalog_password)
UIManager:close(self.download_dialog)
end,
},
{
-- @translators "Stream" here refers to being able to read documents from an OPDS server without downloading them completely, on a page by page basis.
text = _("Stream from page") .. "\u{2B0C}", -- append LEFT RIGHT BLACK ARROW
callback = function()
OPDSPSE:streamPages(acquisition.href, acquisition.count, true, self.root_catalog_username, self.root_catalog_password)
UIManager:close(self.download_dialog)
end,
{
-- @translators "Stream" here refers to being able to read documents from an OPDS server without downloading them completely, on a page by page basis.
text = "\u{23EE} " .. _("Page stream"), -- prepend BLACK LEFT-POINTING DOUBLE TRIANGLE WITH BAR
callback = function()
OPDSPSE:streamPages(acquisition.href, acquisition.count, false, self.root_catalog_username, self.root_catalog_password)
UIManager:close(self.download_dialog)
end,
},
{
-- @translators "Stream" here refers to being able to read documents from an OPDS server without downloading them completely, on a page by page basis.
text = _("Stream from page") .. " \u{23E9}", -- append BLACK RIGHT-POINTING DOUBLE TRIANGLE
callback = function()
OPDSPSE:streamPages(acquisition.href, acquisition.count, true, self.root_catalog_username, self.root_catalog_password)
UIManager:close(self.download_dialog)
end,
},
},
}
if acquisition.last_read then
table.insert(stream_buttons, {
{
-- @translators "Stream" here refers to being able to read documents from an OPDS server without downloading them completely, on a page by page basis.
text = "\u{25B6} " .. _("Resume stream from page") .. " " .. acquisition.last_read, -- prepend BLACK RIGHT-POINTING TRIANGLE
callback = function()
OPDSPSE:streamPages(acquisition.href, acquisition.count, false, self.root_catalog_username, self.root_catalog_password, acquisition.last_read)
UIManager:close(self.download_dialog)
end,
},
})
end
elseif acquisition.type == "borrow" then
table.insert(download_buttons, {
text = _("Borrow"),
@@ -654,7 +671,9 @@ function OPDSBrowser:showDownloads(item)
table.insert(buttons, {}) -- separator
end
if stream_buttons then
table.insert(buttons, stream_buttons)
for _, button_list in ipairs(stream_buttons) do
table.insert(buttons, button_list)
end
table.insert(buttons, {}) -- separator
end
table.insert(buttons, { -- action buttons

View File

@@ -92,7 +92,7 @@ function OPDSPSE:getLastPage(remote_url, username, password)
return last_page;
end
function OPDSPSE:streamPages(remote_url, count, continue, username, password)
function OPDSPSE:streamPages(remote_url, count, continue, username, password, last_page_read)
-- attempt to pull chapter progress from Kavita if user pressed
-- "Page Stream" button.
-- We have to pull the progress here, otherwise the creation of the page_table
@@ -159,6 +159,8 @@ function OPDSPSE:streamPages(remote_url, count, continue, username, password)
UIManager:show(viewer)
if continue then
self:jumpToPage(viewer, count)
elseif last_page_read then
viewer:switchToImageNum(last_page_read)
else
-- add 1 since Kavita's Page count is zero based
-- and ImageViewer is not.