grayleonard / booxtream-epub-drm-remover

Removes all "Social DRM" from booXtream ePub files
178 stars 28 forks source link

wm2() variation #11

Open olberg opened 6 years ago

olberg commented 6 years ago

There seems to be a variation where search string should be "belongs to" instead of "is licensed to".

Artoria2e5 commented 6 years ago

Replacement version for wm2:

def wm2():
    global prefix
    print('\n\n === Removing \'licensing\' watermark (WM2) === \n\n')
    references = set(searchDirectoryForString('.', "is licensed to"))
    references.update(searchDirectoryForString('.', "belongs to"))
    for reference in references:
        soup, tags = findTagsInFile(reference)
        for tag in tags:
            if len(tag.findChildren()) == 0: # No <p> with other <p> inside them
                text_tag = cure_2txt(tag)
                if "is licensed to" in text_tag or "belongs to" in text_tag:
                    print("Found match in file: {0}".format(tag))
                    removeTagFromFile(reference, soup, tag)
    print('\nOK')