feat!: support passing arguments to previewer/preloader/spotter/fetcher (#1966)

This commit is contained in:
三咲雅 · Misaki Masa 2024-11-29 21:48:52 +08:00 committed by sxyazi
parent 37292adfde
commit d72f90356b
No known key found for this signature in database
55 changed files with 703 additions and 458 deletions

View file

@ -1,20 +1,20 @@
local M = {}
function M:peek()
local start, cache = os.clock(), ya.file_cache(self)
if not cache or self:preload() ~= 1 then
function M:peek(job)
local start, cache = os.clock(), ya.file_cache(job)
if not cache or self:preload(job) ~= 1 then
return
end
ya.sleep(math.max(0, PREVIEW.image_delay / 1000 + start - os.clock()))
ya.image_show(cache, self.area)
ya.preview_widgets(self, {})
ya.image_show(cache, job.area)
ya.preview_widgets(job, {})
end
function M:seek() end
function M:preload()
local cache = ya.file_cache(self)
function M:preload(job)
local cache = ya.file_cache(job)
if not cache or fs.cha(cache) then
return 1
end
@ -22,7 +22,7 @@ function M:preload()
local status, err = Command("magick"):args({
"-density",
"200",
tostring(self.file.url),
tostring(job.file.url),
"-flatten",
"-resize",
string.format("%dx%d^", PREVIEW.max_width, PREVIEW.max_height),