Skip to content

Draft: [ProgressSync] Initial implementation of md5 calculation - #106

Draft
elmodor wants to merge 7 commits into
kyxap:mainfrom
elmodor:calculate_md5_hash
Draft

Draft: [ProgressSync] Initial implementation of md5 calculation#106
elmodor wants to merge 7 commits into
kyxap:mainfrom
elmodor:calculate_md5_hash

Conversation

@elmodor

@elmodor elmodor commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

This is a draft idea on how to calculate a md5 hash.

This is a md5 hash based on the filename though, not binary. I have the issue that calibre changes the file for different devices, so a binary match is not possible.

It calculates a md5 hash for every file extension of the ebook and uses these to retrieve the info from the sync server.
It uses the first working md5 hash.

Template has to be set to a string based on the template used to send ebooks to the devices (usually set in device settings).
E.g. {series}{series_index:0>3s| - | - }{title_sort}-{author_sort}
Important is: not to use title or author, but title_sort or author_sort (because calibre automatically changes title to title_sort when the ebook is send to a device ...)
This means that every device has to use the same filename template for it to work and they have to be unique, hence it is probably a good idea to include the series, title an author to avoid any clashes.

Workflow:
Check the checkbox to use Filename matching
Set the Template string in the setting for the sync (below password)
Select one or multiple books in the library
Click the MD5 Hash calculate button on the plugin menu.

In KOReader the options has to be changed from binary to filenames too.

Please share your thoughts if this is something worth improving or your ideas on how to calculate an unified md5 hash automatically.

@elmodor
elmodor marked this pull request as draft August 27, 2025 18:52
@elmodor
elmodor force-pushed the calculate_md5_hash branch from e604150 to 41634a5 Compare August 27, 2025 21:56
@elmodor

elmodor commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

This is as far as I can go without any other input.
I don't like the fact that it requires the Save template to be the same for all devices etc, but this is the only way to make sure the filename (and thus the md5 hash) is the same for all.

Binary md5 sum calculation could be added, it already supports multiple md5 hashes per book. But I don't know how we could calculate it. The binary matching is also not a full md5 sum of the file, but a partial one. So we would need to port the calculation from lua as it is done in KOReader and then somehow? intercept the book when it is being send to a device to calculate the converted book from calibre.
Since I have no idea how to do this, I chose the filename approach.

@harmtemolder @kyxap

@elmodor
elmodor force-pushed the calculate_md5_hash branch from 4f0f166 to 0f78d10 Compare August 28, 2025 12:06
@elmodor

elmodor commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

One issue I can see is that you can now calculate the md5 hash for your whole library and it will try query every single book with a md5 hash.
So it kinda needs another check if a book should be queried or not. Writing "reading" into a text column is not ideal in my opinion. Adding another column as boolean is also cumbersome.

@elmodor elmodor changed the title Draft: Initial implementation of md5 calculation Draft: [ProgressSync] Initial implementation of md5 calculation Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant