View Single Post
Old 10-24-2020, 07:52 AM   #1965
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by NiLuJe View Post
@davidfor:

I've had a weird issue since the Series tab was introduced whereas the metadata migration apparently failed to pickup everything properly, so I've essentially ended up with a lot of stuff with a series set, but no index.

The plugin's update on device metadata thingy didn't help, because the check was failing.

This fixes it on my end:

Code:
diff -NuarpZ KU_2.11.8/action.py KU/action.py
--- KU_2.11.8/action.py 2020-10-19 05:35:00.760538753 +0200
+++ KU/action.py        2020-10-19 05:32:18.913540567 +0200
@@ -3773,14 +3773,16 @@ class KoboUtilitiesAction(InterfaceActio
 
                         if self.supports_series and self.options['series']:
                             debug_print("_update_metadata: self.options['series']", self.options['series'])
-                            debug_print("_update_metadata: newmi.series=", newmi.series, "newmi.series_index=", newmi.series_index)
+                            debug_print("_update_metadata: newmi.series=", newmi.series, "newmi.series_index=", newmi.series_index, "newmi.series_index_string=", newmi.series_index_string)
                             debug_print("_update_metadata: result['Series'] ='%s' result['SeriesNumber'] =%s" % (result["Series"], result["SeriesNumber"]))
                             debug_print("_update_metadata: result['SeriesID'] ='%s' result['SeriesNumberFloat'] =%s" % (result["SeriesID"], result["SeriesNumberFloat"]))
                             debug_print("_update_metadata: result['Series'] == newmi.series =", (result["Series"] == newmi.series))
                             series_index_str = ("%g" % newmi.series_index) if newmi.series_index is not None else None
+                            debug_print("_update_metadata: series_index_str=", series_index_str)
+                            debug_print('_update_metadata: (newmi.series_index_string is not None and result["SeriesNumber"] == newmi.series_index_string) =', (newmi.series_index_string is not None and result["SeriesNumber"] == newmi.series_index_string))
                             debug_print('_update_metadata: result["SeriesNumber"] == series_index_str =', (result["SeriesNumber"] == series_index_str))
-                            debug_print('_update_metadata: not (result["Series"] == newmi.series or result["SeriesNumber"] == series_index_str) =', not (result["Series"] == newmi.series or result["SeriesNumber"] == series_index_str))
-                            if  not (result["Series"] == newmi.series and (result["SeriesNumber"] == newmi.series_index_string or result["SeriesNumber"] == series_index_str)):
+                            debug_print('_update_metadata: not (result["Series"] == newmi.series and ((newmi.series_index_string is not None and result["SeriesNumber"] == newmi.series_index_string) or result["SeriesNumber"] == series_index_str)) =', not (result["Series"] == newmi.series and ((newmi.series_index_string is not None and result["SeriesNumber"] == newmi.series_index_string) or result["SeriesNumber"] == series_index_str)))
+                            if not (result["Series"] == newmi.series and ((newmi.series_index_string is not None and result["SeriesNumber"] == newmi.series_index_string) or result["SeriesNumber"] == series_index_str)):
                                 debug_print("_update_metadata: setting series")
                                 set_clause_columns.append('Series=?')
                                 set_clause_columns.append('SeriesNumber=?')
Basically, on affected books (i.e., all those sent before SeriesID handling), Series was set, SeriesID was set, SeriesNumberFloat was set, but SeriesNumber was None.

I'm not *quite* sure where the newmi.series_index_string thingy is supposed to come from, but it was *always* None on my end, which was screwing up the check, as it was matching on SeriesNumber == newmi.series_index_string == None, which feels wrong .

----

Possibly related, in the Device view, the "Manage series information in device library" button implodes with something like that on those:

Code:
Traceback (most recent call last):
  File "calibre_plugins.koboutilities.action", line 1708, in manage_series_on_device
    d = ManageSeriesDeviceDialog(self.gui, self, seriesBooks, all_series, series_columns)
  File "calibre_plugins.koboutilities.dialogs", line 2161, in __init__
    self.series_column_changed()
  File "calibre_plugins.koboutilities.dialogs", line 2311, in series_column_changed
    initial_series_index = int(first_book.series_index())
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
----

And I'm *guessing* the driver itself is responsible for some of this, because it gets screwy again on every new USBMS session for books that were sent before the SeriesID stuff was implemented .

(I obviously have full automatic metadata handling enabled).

----

It's 5AM, so, I may be talking out of my ass. Apologies in advance .

----

EDIT: Okay, apparently, my on-device metadata.calibre file genuinely had stuff with series_index set to null, for some reason, and getting that to change proved an uphill battle. So, I wiped it, it was re-generated, it's now sane; and a couple USBMS sessions later and a forced metadata update via the patched plugin, and things *appear* to be in order now .
Ugh. Both of these are a mix of Python 3 conversion, and some stupid code. The code in the driver for setting the series info also as a problem if the series index on the device is null. I've have fixed it (though not checked it in) and replaced the code in the plugin with it. It works and is a lot more readable.

I have attached a beta that should fix these problems. If you can give it a go and tell me if there are any problems, that would be good.
Attached Files
File Type: zip KoboUtilities-beta.zip (287.2 KB, 1163 views)
davidfor is offline