harmtemolder / koreader-calibre-plugin

A calibre plugin to synchronize metadata from KOReader to calibre
GNU General Public License v3.0
68 stars 7 forks source link

Add support for books on SD card #2

Open harmtemolder opened 1 year ago

harmtemolder commented 1 year ago

(Copied from #9 on sourcehut.)

See MobileRead Forum: https://www.mobileread.com/forums/showpost.php?p=4223014&postcount=52

ScrambleTheRamble commented 1 year ago

I'm not sure when this was introduced in KoReader but at least 2023.03 supports storing all metadata in the folder "koreader/docsettings/"

Supporting this might solve this for multiple devices

elmodor commented 1 year ago

Having access to the koreader/ folder would also enable reading koreader/history.lua for proper sidecar_changed integration for multiple devices / wireless devices.

The question is: How do we access the koreader/ folder? Currently it seems that the only way to obtain files (at least for wireless connected devices) is through calibres driver. Using the function get_file which is also used to get the sidecars we can access this koreader/ folder if we know the relative path. For wireless connection this is the path relatively to the inbox folder.

I couldn't find any way to obtain that path through calibres driver.

So the only option that currently comes to my mind is a per device configuration where the user has to enter the path of the koreader/ folder manually for each device (and maybe for every connection type? wired vs wireless)(full path vs relative path?).

elmodor commented 1 year ago

If you have some time I would love your input on this @harmtemolder

harmtemolder commented 1 year ago

I don't actually use an SD card with my e-reader, but it has a slot, so I'll go find one to test.

I also read your comments in https://github.com/koreader/koreader/issues/10432 and how you got the get_file function to work with ../../koreader/history.lua. As you said, not very intuitive, but something we could try finding with a scan. (Does history.lua exist? Does koreader/history.lua exist? Does ../koreader/history.lua exist? Etc.) The only caveat would be if books are in a completely different corner of the file system.

harmtemolder commented 1 year ago

I don't see any specific mentions of storing metadata in history.lua in KOReader's release notes: https://github.com/koreader/koreader/releases

But I do see history.lua mentioned in commits as far back as 2016: https://github.com/search?q=repo%3Akoreader%2Fkoreader+%22history.lua%22&type=commits

Not that it really matters when this option was added to KOReader. I was just curious

elmodor commented 1 year ago

The history.lua files contains this information. This is an example of its content:

return {
    [1] = {
        ["file"] = "/full/path/book.epub",
        ["time"] = 1681835840,
    },
}

Obtaining the koreader folder could hence solve two issues:

We could try finding it via a scan but the problem is that for wireless devices we would need to use get_file since (as far as I know) this is the only function that allows us to get access to a file on the connected device. If it fails to find it, then we would need a per device configuration. But I think this would also be different for the connection type?

This might be the way but probably a very complex setup.

kyxap commented 3 months ago

hey @elmodor @ScrambleTheRamble wanted to ask if this still needed? If so can you try it with latest release and let me know what you see on your end? https://github.com/harmtemolder/koreader-calibre-plugin/releases/tag/v0.6.3

kyxap commented 3 months ago

please upvote author post if you want to see this in future releases with👍 or 👎