From adf20e4386254b47b34888cc415c57e96d17ba22 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 16 May 2024 19:33:37 +0200 Subject: fix: DRM-ed EPuBs cannot be opened. --- epubgrep.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/epubgrep.py b/epubgrep.py index 18ab6e4..5fcf2dd 100755 --- a/epubgrep.py +++ b/epubgrep.py @@ -7,6 +7,7 @@ import re import sys import zipfile +from xml.parsers.expat import ExpatError from typing import Any, Dict, List, Optional, Tuple import epub_meta @@ -156,6 +157,9 @@ def grep_book(filename: str, opts: argparse.Namespace, except (epub_meta.EPubException, KeyError, IndexError): log.exception(f'Failed to open {filename}') return None + except ExpatError: + log.warning(f'Cannot open (most likely DRMed) {filename}') + return None book = zipfile.ZipFile(filename) printed_booktitle = False -- cgit