aboutsummaryrefslogtreecommitdiffstats
path: root/epubgrep.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-05-16 19:33:37 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-05-16 19:40:47 +0200
commitadf20e4386254b47b34888cc415c57e96d17ba22 (patch)
treeaf5db6f0c3c5426f89fea45a7c5cc17f770d8b42 /epubgrep.py
parent88c7582a51eb2fc71a80291fa6dab16476ae55d8 (diff)
downloadepubgrep-adf20e4386254b47b34888cc415c57e96d17ba22.tar.gz
fix: DRM-ed EPuBs cannot be opened.
Diffstat (limited to 'epubgrep.py')
-rwxr-xr-xepubgrep.py4
1 files changed, 4 insertions, 0 deletions
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