Fix date column not showing date added when adding zip/rar files that contain an OPF with a calibre timestamp in its metadata

This commit is contained in:
Kovid Goyal 2014-06-05 14:17:01 +05:30
parent 19d0de0059
commit b85d677a1b
2 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,9 @@ def get_metadata(stream):
name, data = extract_member(stream, match=None, name=f)
stream = BytesIO(data)
stream.name = os.path.basename(name)
return get_metadata(stream, stream_type)
mi = get_metadata(stream, stream_type)
mi.timestamp = None
return mi
raise ValueError('No ebook found in RAR archive')

View File

@ -28,14 +28,16 @@ def get_metadata(stream):
with CurrentDir(tdir):
path = zf.extract(f)
mi = get_metadata(open(path,'rb'), stream_type)
if stream_type == 'opf' and mi.application_id == None:
if stream_type == 'opf' and mi.application_id is None:
try:
# zip archive opf files without an application_id were assumed not to have a cover
# reparse the opf and if cover exists read its data from zip archive for the metadata
nmi = zip_opf_metadata(path, zf)
nmi.timestamp = None
return nmi
except:
pass
mi.timestamp = None
return mi
raise ValueError('No ebook found in ZIP archive')