mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-02 06:43:16 +02:00
EPUB metadata: Read ISBN from Penguin epubs that dont correctly specify it
This commit is contained in:
parent
0523376c25
commit
fd61b97f06
1 changed files with 10 additions and 1 deletions
|
|
@ -16,7 +16,7 @@
|
|||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.constants import __appname__, __version__, filesystem_encoding
|
||||
from calibre.ebooks.metadata.toc import TOC
|
||||
from calibre.ebooks.metadata import string_to_authors, MetaInformation
|
||||
from calibre.ebooks.metadata import string_to_authors, MetaInformation, check_isbn
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.utils.date import parse_date, isoformat
|
||||
from calibre.utils.localization import get_lang
|
||||
|
|
@ -863,6 +863,7 @@ def get_identifiers(self):
|
|||
for x in self.XPath(
|
||||
'descendant::*[local-name() = "identifier" and text()]')(
|
||||
self.metadata):
|
||||
found_scheme = False
|
||||
for attr, val in x.attrib.iteritems():
|
||||
if attr.endswith('scheme'):
|
||||
typ = icu_lower(val)
|
||||
|
|
@ -870,7 +871,15 @@ def get_identifiers(self):
|
|||
method='text').strip()
|
||||
if val and typ not in ('calibre', 'uuid'):
|
||||
identifiers[typ] = val
|
||||
found_scheme = True
|
||||
break
|
||||
if not found_scheme:
|
||||
val = etree.tostring(x, with_tail=False, encoding=unicode,
|
||||
method='text').strip()
|
||||
if val.lower().startswith('urn:isbn:'):
|
||||
val = check_isbn(val.split(':')[-1])
|
||||
if val is not None:
|
||||
identifiers['isbn'] = val
|
||||
return identifiers
|
||||
|
||||
@dynamic_property
|
||||
|
|
|
|||
Loading…
Reference in a new issue