From f9fbc4172a5d44f95ffd50b0f105f351b91ea8d7 Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Sun, 12 Dec 2021 09:35:28 +0100 Subject: [PATCH] Support for Google Play books without metadata node --- calibre-plugin/libadobeFulfill.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/calibre-plugin/libadobeFulfill.py b/calibre-plugin/libadobeFulfill.py index 60b34f2..d22efe3 100644 --- a/calibre-plugin/libadobeFulfill.py +++ b/calibre-plugin/libadobeFulfill.py @@ -319,17 +319,22 @@ def fulfill(acsm_file, do_notify = False): adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag) dcNS = lambda tag: '{%s}%s' % ('http://purl.org/dc/elements/1.1/', tag) - mimetype = acsmxml.find("./%s/%s/%s" % (adNS("resourceItemInfo"), adNS("metadata"), dcNS("format"))).text + try: + mimetype = acsmxml.find("./%s/%s/%s" % (adNS("resourceItemInfo"), adNS("metadata"), dcNS("format"))).text - if (mimetype == "application/pdf"): - #print("You're trying to fulfill a PDF file.") + if (mimetype == "application/pdf"): + #print("You're trying to fulfill a PDF file.") + pass + elif (mimetype == "application/epub+zip"): + #print("Trying to fulfill an EPUB file ...") + pass + else: + print("Weird mimetype: %s" % (mimetype)) + print("Continuing anyways ...") + + except: + # Some books, like from Google Play books, use a different format and don't have that metadata tag. pass - elif (mimetype == "application/epub+zip"): - #print("Trying to fulfill an EPUB file ...") - pass - else: - print("Weird mimetype: %s" % (mimetype)) - print("Continuing anyways ...") fulfill_request, adept_ns = buildFulfillRequest(acsmxml)