mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix regression that broke extracting covers from CBR files on windows. Fixes #9038 (Covers no longer being detected in .cbr files)
This commit is contained in:
parent
7dd7914cdc
commit
a311197af5
@ -13,7 +13,7 @@ from tempfile import NamedTemporaryFile
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
from calibre import iswindows, load_library, CurrentDir
|
from calibre import iswindows, load_library, CurrentDir
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory, PersistentTemporaryFile
|
||||||
|
|
||||||
_librar_name = 'libunrar'
|
_librar_name = 'libunrar'
|
||||||
cdll = ctypes.cdll
|
cdll = ctypes.cdll
|
||||||
@ -272,13 +272,18 @@ def extract_member(path, match=re.compile(r'\.(jpg|jpeg|gif|png)\s*$', re.I),
|
|||||||
def extract_first_alphabetically(path):
|
def extract_first_alphabetically(path):
|
||||||
if hasattr(path, 'read'):
|
if hasattr(path, 'read'):
|
||||||
data = path.read()
|
data = path.read()
|
||||||
f = NamedTemporaryFile(suffix='.rar')
|
with PersistentTemporaryFile('.rar') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
f.flush()
|
|
||||||
path = f.name
|
path = f.name
|
||||||
|
|
||||||
names_ = [x for x in names(path) if os.path.splitext(x)[1][1:].lower() in
|
names_ = [x for x in names(path) if os.path.splitext(x)[1][1:].lower() in
|
||||||
('png', 'jpg', 'jpeg', 'gif')]
|
('png', 'jpg', 'jpeg', 'gif')]
|
||||||
names_.sort()
|
names_.sort()
|
||||||
return extract_member(path, name=names_[0], match=None)
|
ans = extract_member(path, name=names_[0], match=None)
|
||||||
|
try:
|
||||||
|
os.remove(path)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user