]> xmof Git - DeDRM.git/commitdiff
Update watermark code
authorNoDRM <no_drm123@protonmail.com>
Mon, 27 Dec 2021 09:39:41 +0000 (10:39 +0100)
committerNoDRM <no_drm123@protonmail.com>
Mon, 27 Dec 2021 09:39:41 +0000 (10:39 +0100)
DeDRM_plugin/__init__.py
DeDRM_plugin/epubwatermark.py

index f433949a8db78bea4107208e21b23944a4ed71fb..0afa7125409d17b387b581e7a269b9321753d276 100644 (file)
@@ -232,7 +232,7 @@ class DeDRM(FileTypePlugin):
                 # Remove watermarks (Amazon or LemonInk) from the OPF file
                 path_to_ebook = watermark.removeOPFwatermarks(self, path_to_ebook) or path_to_ebook
 
-                # Remove watermarks (Adobe or LemonInk) from all HTML and XHTML files
+                # Remove watermarks (Adobe, Pocketbook or LemonInk) from all HTML and XHTML files
                 path_to_ebook = watermark.removeHTMLwatermarks(self, path_to_ebook) or path_to_ebook
 
             
@@ -606,7 +606,9 @@ class DeDRM(FileTypePlugin):
             return self.postProcessEPUB(inf.name)
             #raise DeDRMError("{0} v{1}: Couldn't decrypt after {2:.1f} seconds. DRM free perhaps?".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
 
-    def PDFDecrypt(self,path_to_ebook):
+
+        # No DRM?
+        return self.postProcessEPUB(inf.name)
         import calibre_plugins.dedrm.prefs as prefs
         import calibre_plugins.dedrm.ineptpdf as ineptpdf
         import calibre_plugins.dedrm.lcpdedrm as lcpdedrm
index 954597588c969f2d67d18042140c55305e41b1dd..176c77fd377bc50bcba982c7eab8d177ba32af3c 100644 (file)
@@ -30,7 +30,7 @@ def removeHTMLwatermarks(object, path_to_ebook):
         modded_contents = []
 
         count_adept = 0
-
+        count_pocketbook = 0
         count_lemonink_invisible = 0
         count_lemonink_visible = 0
         lemonink_trackingID = None
@@ -53,6 +53,14 @@ def removeHTMLwatermarks(object, path_to_ebook):
                 if (str_new != pre_remove):
                     count_adept += 1
 
+                # Remove Pocketbook watermarks
+                pre_remove = str_new
+                str_new = re.sub(r'\<div style\=\"padding\:0\;border\:0\;text\-indent\:0\;line\-height\:normal\;margin\:0 1cm 0.5cm 1cm\;[^\"]*opacity:0.0\;[^\"]*text\-decoration\:none\;[^\"]*background\:none\;[^\"]*\"\>(.*?)\<\/div\>', '', str_new)
+
+                if (str_new != pre_remove):
+                    count_pocketbook += 1
+
+
                 # Remove eLibri / LemonInk watermark
                 # Run this in a loop, as it is possible a file has been watermarked twice ...
                 while True: 
@@ -143,6 +151,9 @@ def removeHTMLwatermarks(object, path_to_ebook):
         if (count_lemonink_invisible > 0 or count_lemonink_visible > 0):
             print("Watermark: Successfully stripped {0} visible and {1} invisible LemonInk watermark(s) (\"{2}\") from ebook."
                 .format(count_lemonink_visible, count_lemonink_invisible, lemonink_trackingID))
+            
+        if (count_pocketbook > 0):
+            print("Watermark: Successfully stripped {0} Pocketbook watermark(s) from ebook.".format(count_pocketbook))
 
         return output