|
|
|
@ -12,7 +12,7 @@ function UIToolbox:getPicture(file)
|
|
|
|
|
local function check_extension(cover)
|
|
|
|
|
if cover then
|
|
|
|
|
local itype = string.lower(string.match(cover, ".+%.([^.]+)") or "")
|
|
|
|
|
if not (itype == "png" or itype == "jpg" or itype == "jpeg" or itype == "tiff") then
|
|
|
|
|
if not (itype == "png" or itype == "jpg" or itype == "jpeg") then
|
|
|
|
|
cover = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -70,7 +70,22 @@ function UIToolbox:getPicture(file)
|
|
|
|
|
return check_extension(cover)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function checkoldfile(cover)
|
|
|
|
|
if io.open(cover) then
|
|
|
|
|
return cover
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local cover
|
|
|
|
|
|
|
|
|
|
local oldfile = "temp/" .. file:gsub("/","#") .. "."
|
|
|
|
|
|
|
|
|
|
cover = checkoldfile(oldfile .. "jpg")
|
|
|
|
|
if not cover then cover = checkoldfile(oldfile .. "jpeg") end
|
|
|
|
|
if not cover then cover = checkoldfile(oldfile .. "png") end
|
|
|
|
|
|
|
|
|
|
if not cover then
|
|
|
|
|
|
|
|
|
|
if file then
|
|
|
|
|
pcall(lfs.mkdir("temp"))
|
|
|
|
|
pcall(os.execute("rm -rf " .. epub_folder))
|
|
|
|
@ -88,7 +103,6 @@ function UIToolbox:getPicture(file)
|
|
|
|
|
else
|
|
|
|
|
contentpath = ""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
pcall(os.execute("unzip \"" .. file .. "\" \"" .. contentopf .. "\" -oq -d " .. epub_folder)) -- read content.opf
|
|
|
|
|
|
|
|
|
|
cover = try_content_opf("^%s*<meta name=\"cover\"","content=",true) -- Make Room
|
|
|
|
@ -103,7 +117,16 @@ function UIToolbox:getPicture(file)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return check_extension(cover)
|
|
|
|
|
cover=check_extension(cover)
|
|
|
|
|
if cover then
|
|
|
|
|
oldfile = oldfile .. string.lower(string.match(cover, ".+%.([^.]+)"))
|
|
|
|
|
pcall(os.execute('mv "' .. cover .. '" "' .. oldfile .. '"'))
|
|
|
|
|
cover = oldfile
|
|
|
|
|
pcall(os.execute('find temp/#mnt#* -mtime +30 -exec rm -v {} \\;'))
|
|
|
|
|
end
|
|
|
|
|
pcall(os.execute("rm -rf " .. epub_folder))
|
|
|
|
|
end
|
|
|
|
|
return cover
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function UIToolbox:getRandomPicture(dir)
|
|
|
|
|