From 2779334e4a76c4ec06186bba7d34bc12904ae13f Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Fri, 13 May 2022 16:38:23 +0200 Subject: [PATCH] Fix misidentification as passHash book --- calibre-plugin/libadobeFulfill.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/calibre-plugin/libadobeFulfill.py b/calibre-plugin/libadobeFulfill.py index 82bf05a..448f6a6 100644 --- a/calibre-plugin/libadobeFulfill.py +++ b/calibre-plugin/libadobeFulfill.py @@ -649,27 +649,27 @@ def performFulfillmentNotification(fulfillmentResultToken, forceOptional = False # "Normal" Adobe fulfillment user = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("user"))).text except AttributeError: - # B&N Adobe PassHash fulfillment - user = body.find("./%s" % (adNS("user"))).text + # B&N Adobe PassHash fulfillment. Doesn't use notifications usually ... + #user = body.find("./%s" % (adNS("user"))).text + print("Skipping notify due to passHash?") + print("If this is not a passHash book pls open a bug report.") + continue if (device is None): try: # "Normal" Adobe fulfillment device = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("device"))).text except: - # B&N Adobe PassHash fulfillment without device ID. - # PassHash books aren't linked to a particular device, so there's no ID to send to Adobe. - # If I understand Adobe's documentation correctly, PassHash books do not support notifications - # and are not supposed to contain notify tags, so lets just skip if that's the case. - print("Skipping notify due to passHash") - continue - + print("Missing deviceID for loan metadata ... why?") + # I have no idea if this behaviour is correct, need to do more testing on loaned books without deviceID full_text = "" full_text += "%s" % user - full_text += "%s" % device + + if device is not None: + full_text += "%s" % device # ADE 4.0 apparently changed the order of these two elements. @@ -751,6 +751,11 @@ def performFulfillmentNotification(fulfillmentResultToken, forceOptional = False errmsg_crit += "ERROR\n" + url + "\n" + msg + "\n\n" + if device is None and errmsg_crit != "": + errmsg_crit = "" + print("Skipping critical notification failure due to weird book.") + + if errmsg_crit == "": return True, ""