Fix misidentification as passHash book

This commit is contained in:
Florian Bach 2022-05-13 16:38:23 +02:00
parent 9346b888d3
commit 2779334e4a

View File

@ -649,27 +649,27 @@ def performFulfillmentNotification(fulfillmentResultToken, forceOptional = False
# "Normal" Adobe fulfillment # "Normal" Adobe fulfillment
user = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("user"))).text user = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("user"))).text
except AttributeError: except AttributeError:
# B&N Adobe PassHash fulfillment # B&N Adobe PassHash fulfillment. Doesn't use notifications usually ...
user = body.find("./%s" % (adNS("user"))).text #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): if (device is None):
try: try:
# "Normal" Adobe fulfillment # "Normal" Adobe fulfillment
device = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("device"))).text device = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("device"))).text
except: except:
# B&N Adobe PassHash fulfillment without device ID. print("Missing deviceID for loan metadata ... why?")
# PassHash books aren't linked to a particular device, so there's no ID to send to Adobe. # I have no idea if this behaviour is correct, need to do more testing on loaned books without deviceID
# 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
full_text = "<adept:notification xmlns:adept=\"http://ns.adobe.com/adept\">" full_text = "<adept:notification xmlns:adept=\"http://ns.adobe.com/adept\">"
full_text += "<adept:user>%s</adept:user>" % user full_text += "<adept:user>%s</adept:user>" % user
full_text += "<adept:device>%s</adept:device>" % device
if device is not None:
full_text += "<adept:device>%s</adept:device>" % device
# ADE 4.0 apparently changed the order of these two elements. # 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" 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 == "": if errmsg_crit == "":
return True, "" return True, ""