Skip to content

Commit

Permalink
Release v0.5.2-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
harmtemolder committed May 22, 2023
1 parent b04b432 commit e71f567
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -89,7 +89,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
@@ -1,4 +1,4 @@
version = 0.5.1-beta
version = 0.5.2-beta
zip_file = releases/KOReader Sync v$(version).zip
zip_contents = about.txt LICENSE plugin-import-name-koreader.txt *.py *.md images/*.png

Expand Down
64 changes: 37 additions & 27 deletions README.md
Expand Up @@ -8,47 +8,50 @@
A calibre plugin to synchronize metadata from KOReader to calibre.

[KOReader](https://koreader.rocks/) creates sidecar files that hold read progress and annotations. This plugin reads the data from those sidecar files and updates calibre's metadata based on them. It is inspired by [the Kobo Utilities plugin](https://www.mobileread.com/forums/showthread.php?t=215339), that synchronizes reading progress between the original Kobo firmware (Nickel) and custom columns in calibre.
[KOReader](https://koreader.rocks/) creates sidecar files that hold read progress and annotations. This plugin reads the data from those sidecar files and updates calibre's metadata based on them. It is inspired by [the Kobo Utilities plugin](https://www.mobileread.com/forums/showthread.php?t=215339), that synchronizes reading progress between the original Kobo firmware ("Nickel") and custom columns in calibre.

Note that at the moment the sync is primarily one-way—from the KOReader device to calibre and only works for USB and [wireless](https://github.com/koreader/koreader/wiki/Calibre-wireless-connection) devices. For the latter, you'll need [KOReader 2021.04 or newer](https://github.com/koreader/koreader/releases).
Note that at the moment the sync is primarily one-way—from the KOReader device to calibre, and only works for USB and [wireless](https://github.com/koreader/koreader/wiki/Calibre-wireless-connection) devices. For the latter, you'll need [KOReader 2021.04 or newer](https://github.com/koreader/koreader/releases).

Pushing metadata from Calibre to KOReader currently works only for books which do not have KOReader sidecar files, and of course requires the raw metadata column to be mapped. The use-case is for e.g. setting up a new device, or if a book was removed from your device and you've now added it back. This has been tested for Calibre's Connect to Folder and Custom USB Device modes. It does not seem to work for the Kobo Touch device driver nor with wireless connections, but I (@charlesangus) find those don't communicate perfectly with Calibre/KOReader in any case... I haven't disabled it for other devices - it may be a quirk in my setup which is causing it to fail, and it may work fine for you.
Pushing metadata from calibre to KOReader currently works only for books which do not have KOReader sidecar files, and of course requires the raw metadata column to be mapped. The use-case is for setting up a new device, or if a book was removed from your device and you've now added it back. This has been tested for calibre's Connect to Folder and Custom USB Device modes. It does not seem to work for the Kobo Touch device driver nor with wireless connections, but I (@charlesangus) find those don't communicate perfectly with Calibre/KOReader in any case... I haven't disabled it for other devices - it may be a quirk in my setup which is causing it to fail, and it may work fine for you.

Releases will also be uploaded to [this plugin thread on the MobileRead Forums](https://www.mobileread.com/forums/showthread.php?p=4060141). If you are on there as well, please let me know what you think of the plugin in that thread.

## Using this plugin

### Download and install

1. Go to your calibre's “Preferences” > “Plugins” > “Get new plugins” and search for “KOReader Sync”
2. Click “Install”
1. Go to your calibre's _Preferences_ > _Plugins_ > _Get new plugins_ and search for _KOReader Sync_
2. Click _Install_
3. Restart calibre

#### Alternatively

1. Download the latest release from [here](https://github.com/harmtemolder/koreader-calibre-plugin/tree/main/releases).
2. Go to your calibre's “Preferences” > “Plugins” > “Load plugin from file” and point it to the downloaded ZIP file
2. Go to your calibre's _Preferences_ > _Plugins_ > _Load plugin from file_ and point it to the downloaded ZIP file
3. Restart calibre

### Setup

1. Pick and choose the metadata you would like to sync and create the appropriate columns in calibre. These are your options:
- A “Floating point numbers” column to store the **current percent read**, with “Format for numbers” set to `{:.0%}`.
- An “Integers” column to store the **current percent read**.
- A regular “Text” column to store the **location you last stopped reading at**.
- A “Rating” column to store your **rating** of the book, as entered on the book's status page.
- A “Long text” column to store your **review** of the book, as entered on the book's status page.
- A “Long text” column to store your **bookmarks and highlights** of the book, with “Interpret this column as” set to “Plain text formatted using markdown”. (Highlights are an unordered list with their metadata in an HTML comment.)
- A regular “Text” column to store the **reading status** of the book, as entered on the book status page (“Finished”, “Reading”, “On hold”).
- A “Date” column to store **the date on which the first highlight or bookmark was made**. (This is probably around the time you started reading.)
- A “Date” column to store **the date on which the last highlight or bookmark was made**. (This is probably around the time you finished reading.)
- A regular “Text” column to store the **MD5 hash** KOReader uses to sync progress to a [**KOReader Sync Server**](https://github.com/koreader/koreader-sync-server#koreader-sync-server). (“Progress sync” in the KOReader app.) This might allow for syncing progress to calibre without having to connect your KOReader device, in the future.
- A “Long text” column to store the **raw contents of the metadata sidecar**, with “Interpret this column as” set to “Plain text”. This is required to sync metadata back to KOReader sidecars.
10. Add “KOReader Sync” to “main toolbar when a device is connected”, if it isn't there already.
11. Right-click the “KOReader Sync” icon and “Configure”.
- A _Floating point numbers_ column to store the **current percent read**, with _Format for numbers_ set to `{:.0%}`.
- An _Integers_ column to store the **current percent read**.
- A regular _Text_ column to store the **location you last stopped reading at**.
- A _Rating_ column to store your **rating** of the book, as entered on the book's status page.
- A _Long text_ column to store your **review** of the book, as entered on the book's status page.
- A regular _Text_ column to store the **reading status** of the book, as entered on the book status page (_Finished_, _Reading_, _On hold_).
- A _Yes/No_ column to store the **reading status** of the book, as a boolean (_Yes_ = _Finished_, _No_ = everything else).
- A _Date_ column to store **the date on which the first highlight or bookmark was made**. (This is probably around the time you started reading.)
- A _Date_ column to store **the date on which the last highlight or bookmark was made**. (This is probably around the time you finished reading.)
- A _Long text_ column to store your **bookmarks and highlights** of the book, with _Interpret this column as_ set to _Plain text formatted using markdown_. (Highlights are an unordered list with their metadata in an HTML comment.)
- A regular _Text_ column to store the **MD5 hash** KOReader uses to sync progress to a [**KOReader Sync Server**](https://github.com/koreader/koreader-sync-server#koreader-sync-server). (_Progress sync_ in the KOReader app.) This might allow for syncing progress to calibre without having to connect your KOReader device, in the future.
- A _Date_ column to store **when the last sync was performed**.
- A _Date_ column to store **when the sidecar file was last modified**.',
- A _Long text_ column to store the **contents of the metadata sidecar** as JSON, with _Interpret this column as_ set to _Plain text_. This is required to sync metadata back to KOReader sidecars.
10. Add _KOReader Sync_ to _main toolbar when a device is connected_, if it isn't there already.
11. Right-click the _KOReader Sync_ icon and _Configure_.
12. Map the metadata you want to sync to the newly created calibre columns.
13. Click “OK” to save your mapping.
14. From now on just click the “KOReader Sync” icon to sync all mapped metadata for all books on the connected device to calibre.
13. Click _OK_ to save your mapping.
14. From now on just click the _KOReader Sync_ icon to sync all mapped metadata for all books on the connected device to calibre.

### Things to consider

Expand Down Expand Up @@ -89,7 +92,7 @@ If you encounter any issues with the plugin, please submit them [here](https://g
### Notes & Tips

- My first attempt was actually to sync calibre with KOReader's read progress through the progress sync plugin and a [sync server](https://github.com/koreader/koreader-sync-server). Read [here](https://github.com/koreader/koreader/issues/6399#issuecomment-721826362) why that did not work. This plugin might actually make that possible now by allowing you to store KOReader's MD5 hash in calibre...
- calibre allows you to auto-connect to a folder device on boot, which greatly speeds up your workflow when testing. You can find this under Preferences > Tweaks, search for `auto_connect_to_folder`. Point that to the `dummy_device` folder in this repository. (I have included royalty free EPUBs for your and my convenience.)
- calibre allows you to auto-connect to a folder device on boot, which greatly speeds up your workflow when testing. You can find this under "Preferences" > "Tweaks", search for `auto_connect_to_folder`. Point that to the `dummy_device` folder in this repository. (I have included royalty free EPUBs for your and my convenience.)
- If you're testing and don't actually want to update any metadata, set `DRY_RUN` to `True` in `__init__.py`.
- I work in PyCharm, which offers a remote debugging server. To enable that in this plugin, set `PYDEVD` to `True` in `__init__.py`.You might need to change `sys.path.append` in `action.py`.
- The supported device drivers can be found in [the `SUPPORTED_DEVICES` list in `config.py`](https://github.com/harmtemolder/koreader-calibre-plugin/blob/main/config.py#L30). Adding a new type here is the first step to adding support, but make sure all features are tested thoroughly before releasing a version with an added device
Expand All @@ -110,7 +113,7 @@ make zip load

### Building a release

Make sure you have the dependencies and have set the correct version number in `__init__.py`, `pluginIndexKOReaderSync.txt` and `Makefile`. Also update [Changelog](#Changelog). Then:
Make sure you have the dependencies and have set the correct version number in `__init__.py`, `pluginIndexKOReaderSync.txt` and `Makefile`. Also update [Changelog](#changelog). Then:

```shell
make zip
Expand All @@ -136,22 +139,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [0.5.2-beta] - ?
## [0.5.2-beta] - 2023-05-22

- Many thanks to @elmodor and igorius for their help!

### Added

- Added config option to only sync if the metadata is newer than the data stored in calibre (will fallback to "Percent read column" if no "Date Modified column" exists or can not be obtained)
- Added config option to not sync if the book has already been marked as finished (via "Percent read column" or "Reading status column")
- Added a yes/no column for read status (based on changes from igorius at mobilread)
- Added a yes/no column for read status (based on [changes from igorius at MobileRead](https://www.mobileread.com/forums/showpost.php?p=4323088&postcount=90))

### Changed

- Pylint cleanup
- Update README to match new columns
- Update dummy device and library to match new columns

### Fixed

- Fixed crash for wireless connected devices while trying to get the "Date Modified column" value
- Fixed setting correct sync status for `column_status` if no status is send from koreader
- Fixed setting correct sync status for `column_status` if no status is sent from KOReader

## [0.5.1-beta] - 2022-12-27

Expand Down Expand Up @@ -326,5 +333,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[0.3.1-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/blob/main/releases/KOReader%20Sync%20v0.3.1-beta.zip
[0.3.2-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/blob/main/releases/KOReader%20Sync%20v0.3.2-beta.zip
[0.4.0-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/blob/main/releases/KOReader%20Sync%20v0.4.0-beta.zip
[0.4.1-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/blob/main/releases/KOReader%20Sync%20v0.4.1-beta.zip
[0.4.1-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/releases/tag/v0.4.1-beta
[0.5.0-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/releases/tag/v0.5.0-beta
[0.5.1-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/releases/tag/v0.5.1-beta
[0.5.2-beta]: https://github.com/harmtemolder/koreader-calibre-plugin/releases/tag/v0.5.2-beta
[unreleased]: https://github.com/harmtemolder/koreader-calibre-plugin
4 changes: 2 additions & 2 deletions __init__.py
Expand Up @@ -31,9 +31,9 @@

class KoreaderSync(InterfaceActionBase):
name = 'KOReader Sync'
description = 'Get metadata from a locally connected KOReader device '
description = 'Get metadata from a connected KOReader device'
author = 'harmtemolder'
version = (0, 5, 1)
version = (0, 5, 2)
minimum_calibre_version = (5, 0, 1) # Because Python 3
config = JSONConfig(os.path.join('plugins', 'KOReader Sync.json'))
actual_plugin = 'calibre_plugins.koreader.action:KoreaderAction'
Expand Down
29 changes: 14 additions & 15 deletions action.py
Expand Up @@ -38,7 +38,7 @@
from calibre.constants import numeric_version

__license__ = 'GNU GPLv3'
__copyright__ = '2021, harmtemolder <mail at harmtemolder.com>'
__copyright__ = '2023, harmtemolder <mail at harmtemolder.com>'
__docformat__ = 'restructuredtext en'

if numeric_version >= (5, 5, 0):
Expand All @@ -65,7 +65,7 @@

class KoreaderAction(InterfaceAction):
name = KoreaderSync.name
action_spec = (name, 'copy-to-library.png', KoreaderSync.description, None)
action_spec = (name, 'edit-redo.png', KoreaderSync.description, None)
action_add_menu = True
action_menu_clone_qaction = 'Sync from KOReader'
dont_add_to = frozenset(
Expand Down Expand Up @@ -96,12 +96,12 @@ def genesis(self):
# Right-click menu (already includes left-click action)
self.create_menu_action(
self.qaction.menu(),
'Sync Missing Sidecars to KOReader',
'Sync Missing Sidecars to KOReader',
icon='config.png',
description='Where Calibre has a raw metadata entry but KOReader '
'does not have a sidecar file, push the metadata from Calibre '
'to a new sidecar file.',
'Sync missing to KOReader',
'Sync missing to KOReader',
icon='edit-undo.png',
description='If calibre has an entry in the "Raw sidecar column", '
'but KOReader does not have a sidecar file, push the '
'metadata from calibre to a new sidecar file.',
triggered=self.sync_missing_sidecars_to_koreader
)

Expand All @@ -123,7 +123,7 @@ def genesis(self):
'Readme for KOReader Sync',
'Readme',
icon='dialog_question.png',
description='About KOReader Sync',
description='Readme for KOReader Sync',
triggered=self.show_readme
)

Expand All @@ -143,8 +143,7 @@ def show_readme(self):
debug_print = partial(module_debug_print, 'KoreaderAction:show_readme:')
debug_print('start')
readme_url = QUrl(
'https://git.sr.ht/~harmtemolder/koreader-calibre'
'-plugin#koreader-calibre-plugin'
'https://github.com/harmtemolder/koreader-calibre-plugin#readme'
)
open_url(readme_url)

Expand Down Expand Up @@ -583,7 +582,7 @@ def sync_missing_sidecars_to_koreader(self):
'KoreaderAction:sync_missing_sidecars_to_koreader:'
)

if CONFIG["column_sidecar"] is '':
if CONFIG["column_sidecar"] == '':
error_dialog(
self.gui,
'Failure',
Expand Down Expand Up @@ -618,7 +617,7 @@ def sync_missing_sidecars_to_koreader(self):
num_fail = 0
for book_uuid, path in sidecar_paths_not_exist.items():
result, details = self.push_metadata_to_koreader_sidecar(book_uuid, path)
if result is "success":
if result == "success":
num_success += 1
results.append(
{
Expand All @@ -627,7 +626,7 @@ def sync_missing_sidecars_to_koreader(self):
'sidecar_path': path,
}
)
elif result is "failure":
elif result == "failure":
num_fail += 1
results.append(
{
Expand All @@ -636,7 +635,7 @@ def sync_missing_sidecars_to_koreader(self):
'sidecar_path': path,
}
)
elif result is "no_metadata":
elif result == "no_metadata":
num_no_metadata += 1
results.append(
{
Expand Down

0 comments on commit e71f567

Please sign in to comment.