mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF metadata: If one of the keywords in the PDF is a valid ISBN, use it as the ISBN for the book
This commit is contained in:
parent
395eba9518
commit
b05be6f902
@ -10,7 +10,7 @@ from functools import partial
|
|||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.ebooks.metadata import MetaInformation, string_to_authors
|
from calibre.ebooks.metadata import MetaInformation, string_to_authors, check_isbn
|
||||||
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
||||||
|
|
||||||
#_isbn_pat = re.compile(r'ISBN[: ]*([-0-9Xx]+)')
|
#_isbn_pat = re.compile(r'ISBN[: ]*([-0-9Xx]+)')
|
||||||
@ -118,6 +118,10 @@ def get_metadata(stream, cover=True):
|
|||||||
mi.tags = []
|
mi.tags = []
|
||||||
if keywords:
|
if keywords:
|
||||||
mi.tags = [x.strip() for x in keywords.split(',')]
|
mi.tags = [x.strip() for x in keywords.split(',')]
|
||||||
|
isbn = [check_isbn(x) for x in mi.tags if check_isbn(x)]
|
||||||
|
if isbn:
|
||||||
|
mi.isbn = isbn = isbn[0]
|
||||||
|
mi.tags = [x for x in mi.tags if check_isbn(x) != isbn]
|
||||||
|
|
||||||
subject = info.get('Subject', None)
|
subject = info.get('Subject', None)
|
||||||
if subject:
|
if subject:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user