mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fail on reading PDF metadata gracefully. version 0.3.108.
This commit is contained in:
parent
b8a1906aa3
commit
bcfc7d978a
@ -13,7 +13,7 @@
|
||||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
''' E-book management software'''
|
||||
__version__ = "0.3.107"
|
||||
__version__ = "0.3.108"
|
||||
__docformat__ = "epytext"
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
__appname__ = 'libprs500'
|
||||
|
@ -27,6 +27,7 @@ def get_metadata(stream):
|
||||
title = 'Unknown'
|
||||
mi = MetaInformation(title, 'Unknown')
|
||||
stream.seek(0)
|
||||
try:
|
||||
info = PdfFileReader(stream).getDocumentInfo()
|
||||
if info.title:
|
||||
mi.title = title
|
||||
@ -39,6 +40,8 @@ def get_metadata(stream):
|
||||
mi.author = info.author
|
||||
if info.subject:
|
||||
mi.category = info.subject
|
||||
except Exception, err:
|
||||
print >>sys.stderr, 'Couldn\'t read metadata from pdf: % with error %s'%(mi.title, str(err))
|
||||
return mi
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user