From 9346b888d396b496ab8b2b7684e29c1002d8bf9a Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Fri, 13 May 2022 16:23:14 +0200 Subject: [PATCH] Fix loans without deviceID --- calibre-plugin/libadobeFulfill.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/calibre-plugin/libadobeFulfill.py b/calibre-plugin/libadobeFulfill.py index a16b5e1..82bf05a 100644 --- a/calibre-plugin/libadobeFulfill.py +++ b/calibre-plugin/libadobeFulfill.py @@ -487,7 +487,10 @@ def updateLoanReturnData(fulfillmentResultToken): book_name = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("metadata"), dcNS("title"))).text userUUID = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("user"))).text - deviceUUID = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("device"))).text + try: + deviceUUID = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("device"))).text + except: + deviceUUID = None loanid = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("fulfillment"))).text permissions = fulfillmentResultToken.find("./%s/%s/%s/%s" % (adNS("fulfillmentResult"), adNS("resourceItemInfo"), adNS("licenseToken"), adNS("permissions"))) @@ -540,17 +543,24 @@ def updateLoanReturnData(fulfillmentResultToken): def tryReturnBook(bookData): try: user = bookData["user"] - device = bookData["device"] loanID = bookData["loanID"] operatorURL = bookData["operatorURL"] + device = None except: print("Invalid book data!") return False, "Invalid book data" + try: + device = bookData["device"] + except: + pass + + req_data = "" req_data += "" req_data += "%s" % (user) - req_data += "%s" % (device) + if device is not None: + req_data += "%s" % (device) req_data += "%s" % (loanID) req_data += addNonce() req_data += ""