Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements for device.py: #2315

Merged
merged 3 commits into from
Jun 23, 2024

Conversation

kyxap
Copy link
Contributor

@kyxap kyxap commented Jun 23, 2024

  • multiple author match support
  • debug print
  • NO_AUTHOR_MATCH tag for Author mismatch
  • '&' > 'and' support in book title

Before:
before

After:
after
Note: Author C - with NO_AUTHOR_MATCH when Author changed in calibre after book was pushed to the device

Also tried to report this as a bug but failed :| https://bugs.launchpad.net/calibre/+bug/2070045

Windows 11
Kobo Clara BW

- multiple author match support
- debug print
- NO_AUTHOR_MATCH tag for Author mismatch
- '&' > 'and' support in book title
@cbhaley
Copy link
Contributor

cbhaley commented Jun 23, 2024

Ahhh, I see why I couldn't replicate your problem. You are dealing with books sideloaded on the Kobo some way other than by calibre. This means the UUID is wrong/non-existent and the book metadata might have nothing to do with the metadata in calibre. The "Match book in library" option in the device view context menu exists for these cases.

@kovid: I am nervous about the change to clean_string changing '&' to 'and'. It isn't clear how this change will affect matching on non-Kobo devices. I am also a bit nervous about using "NO_AUTHOR_MATCH" value to indicate that the book didn't match. A book having a value in that column means the book did match, specifying how the book matched. Finally, it isn't clear how this might affect "Match book in library" and "Show matched book in library" in the device view context menu.

@kovidgoyal
Copy link
Owner

Replacing & with and is definitely not correct. device.py cannot have device specific fixes. If you want to make such a fix, the place to do it is the kobo driver. And I agree NO_AUTHOR_MATCH is not appropriate.

Matching if only one author matches but all authors dont match is probably OK.

Finally, if you want a debug_print() function use the existing one from usbms/driver.py

@kyxap
Copy link
Contributor Author

kyxap commented Jun 23, 2024

You are dealing with books sideloaded on the Kobo some way other than by calibre.

nope, all books were send to kobo from calibre, I thought there a problem of how fast it pull the data from db vs checking root metadata (it saves matched info there, right?). Anyway... after another round of testing I've found that if I delete root metadata calibre going to create new metadata but seems some peace's of information will be missing and that why I'm ending up with Author, tittle logic check, lol... now it make more sense to me :D But if I send any new book without device disconnect it will add missing data (metadata file updates) and list will be looking like:
image
So seems another bug to me.

The "Match book in library" option in the device view context menu exists for these cases.

I dont see Match book in library in UI or in src, do you mean Read metadata from files on device? If so it seems if I turn it off it does not do anything differently

I am nervous about the change to clean_string changing '&' to 'and'.

Yeah... I actually was not 100% sure about it and just found where was an issue. Going to remove.

Finally, if you want a debug_print() function use the existing one from usbms/driver.py

what function? I see there same if debug print use

@cbhaley
Copy link
Contributor

cbhaley commented Jun 23, 2024

The standard kobo driver doesn't use metadata.calibre for anything. It builds the booklist from the db. New books must be scanned which happens after a disconnect. Existing books aren't rescanned; they must be deleted before being resent.

The match books function is in the context menu for the device view.

@kovidgoyal
Copy link
Owner

The debug_print() function at line 26 of usbms/driver.py

@kyxap
Copy link
Contributor Author

kyxap commented Jun 23, 2024

The debug_print() function at line 26 of usbms/driver.py

my bad, was looking in wrong place, updated

@kyxap
Copy link
Contributor Author

kyxap commented Jun 23, 2024

also is there documentation of use of metadata.calibre and .metadata.calibre (wireless metadata) ?

@cbhaley
Copy link
Contributor

cbhaley commented Jun 23, 2024

As I said before, the wireless driver doesn't use any form of metadata.calibre. The remote device supplies the metadata.

As for documentation, metadata.calibre is built from the book list supplied by the device driver. Various drivers build the booklist in different ways. It is the driver-built booklist that device.py users.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 23, 2024 via email

@kovidgoyal kovidgoyal merged commit aa4c720 into kovidgoyal:master Jun 23, 2024
@kyxap kyxap deleted the device-kobo-improvements branch June 23, 2024 16:52
@cbhaley
Copy link
Contributor

cbhaley commented Jun 23, 2024

The "Match book in library" option in the device view context menu exists for these cases.

I dont see Match book in library in UI or in src, do you mean Read metadata from files on device? If so it seems if I turn it off it does not do anything differently

The device view context menu is defined here:

defs['action-layout-context-menu-device'] = (

The device view context menu is set up here:

populate_menu(dm, gprefs['action-layout-context-menu-device'], self.iactions)

The plugin used in the above context men for the 'Match Books' action is here: https://github.com/kovidgoyal/calibre/blob/master/src/calibre/gui2/actions/match_books.py

It uses this dialog to do the work: https://github.com/kovidgoyal/calibre/blob/master/src/calibre/gui2/dialogs/match_books.py

Note that you must choose 'Update cached metadata on device' in the device view toolbar to cause the changes to be given to the actual device driver. The usual method is calling "sync_booklists()" in the driver, which stores the changes however it does. This call is done by a signal that (eventually) calls this method in device.py:

def update_metadata_on_device(self):

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.

3 participants