]> xmof Git - DeDRM.git/commitdiff
Fix watermark stuff
authorNoDRM <no_drm123@protonmail.com>
Mon, 29 Nov 2021 15:33:45 +0000 (16:33 +0100)
committerNoDRM <no_drm123@protonmail.com>
Mon, 29 Nov 2021 15:33:45 +0000 (16:33 +0100)
DeDRM_plugin/epubwatermark.py

index e6115b3b37cfb862871cd763b526e6a4dffb9ad2..954597588c969f2d67d18042140c55305e41b1dd 100644 (file)
@@ -198,7 +198,9 @@ def removeOPFwatermarks(object, path_to_ebook):
             # This regex replaces all "idX_Y" IDs with "id_Y", removing the watermark IDs.
             pre_remove = container_str_new
             container_str_new = re.sub(r'((\r\n|\r|\n)\s*)?\<\!\-\-\s*Wygenerowane przez elibri dla zamówienia numer [0-9a-fA-F]+\s*\-\-\>', '', container_str_new)
-            container_str_new = re.sub(r'\=\"id[0-9]+_([0-9]+)\"', r'="id_\1"', container_str_new)
+            if pre_remove != container_str_new:
+                # To prevent this Regex from applying to books without that watermark, only do that if the watermark above was found.
+                container_str_new = re.sub(r'\=\"id[0-9]+_([0-9]+)\"', r'="id_\1"', container_str_new)
             if pre_remove != container_str_new:
                 had_elibri = True