From 60e8a67dcf5984b3b0b080f341aeef3ec24dab01 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Mar 2023 11:51:15 +0530 Subject: [PATCH] Function to get headers from RAR files --- src/calibre/utils/unrar.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/utils/unrar.py b/src/calibre/utils/unrar.py index e57cea62c0..87a96d1fbd 100644 --- a/src/calibre/utils/unrar.py +++ b/src/calibre/utils/unrar.py @@ -61,6 +61,14 @@ def names(path_or_stream): yield from names(path, only_useful=True) +def headers(path_or_stream): + from unrardll import headers, is_useful + with StreamAsPath(path_or_stream) as path: + for h in headers(path): + if is_useful(h): + yield h + + def comment(path_or_stream): from unrardll import comment with StreamAsPath(path_or_stream) as path: