Thanks for the info, chaley
Quote:
Originally Posted by chaley
Is there something specific you are looking for?
|
Yeah. I tried to figure out why the code I was writting didn't work on my BQ cervantes 4. I thought than other devices could have the same issues.
Basically is a function to search calibre metadata from n calibre libraries. Works with connect to folder, our own backed in wireless client and most of calibre device drivers, but fails on my BQ.
In the end I wrote a helper function to workaround the limitation. now looks this way:
Code:
local function getAllMetadata(t)
local books = {}
for path, enabled in pairs(t) do
if enabled and CalibreMetadata:init(path, true) then
local books_path
local ok_lpath, subdir = hasValidLpath(CalibreMetadata.drive.device_name)
if not ok_lpath then
books_path = path .. "/" .. subdir
else
books_path = path
end
for _, book in ipairs(CalibreMetadata.books) do
local slim_book = {}
slim_book.title = book.title
slim_book.lpath = book.lpath
slim_book.authors = book.authors
slim_book.series = book.series
slim_book.tags = book.tags
slim_book.size = book.size
slim_book.rootpath = books_path
table.insert(books, #books + 1, slim_book)
end
CalibreMetadata:clean()
end
end
return books
end
the helper function hasValidLpath is just a workaround for BQ devices:
Code:
-- some calibre drivers don't report a valid lpath
local function hasValidLpath(name)
if type(name) ~= "string" then return true end
local function deviceIs(kind)
return string.match(string.upper(name), string.upper(kind))
end
if deviceIs("bq") then
return false, "Books"
else
-- deviceIs "Kobo"/"Amazon"/"Folder"/"KOReader"
return true
end
end
The reason why I need the workaround is: when using BQ Cervantes device driver "metadata.calibre" is put on the root of the USB share. Books are placed on "Books/"
but the lpath of books doesn't join "Books" to the name of the file.
If I disable the device driver and connect to the root dir with connect to folder then calibre is able to fix the issue and now books have the expected lpath.
I searched
https://github.com/kovidgoyal/calibr...EBOOK_DIR_MAIN and I'm now pretty sure it's the fault on that specific driver and not something that need s special care on every device I'm trying to support.