summaryrefslogtreecommitdiff
path: root/bibtool/extract.py
diff options
context:
space:
mode:
Diffstat (limited to 'bibtool/extract.py')
-rw-r--r--bibtool/extract.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bibtool/extract.py b/bibtool/extract.py
index 6955dbe..cefbe8f 100644
--- a/bibtool/extract.py
+++ b/bibtool/extract.py
@@ -42,8 +42,9 @@ def _get_data_for_doi(doi):
return bibtexparser.loads(bibtex)
-def _handle_pdf(filename):
- doi = _extract_doi(filename)
+def _handle_pdf(filename, doi):
+ if not doi:
+ doi = _extract_doi(filename)
if not doi:
raise Exception('Could not extract a DOI from the PDF file')
@@ -51,8 +52,8 @@ def _handle_pdf(filename):
return _get_data_for_doi(doi)
-def get_bibtex_data(filename):
+def get_bibtex_data(filename, doi):
mtype, _ = mimetypes.guess_type(filename)
if mtype == 'application/pdf':
- return _handle_pdf(filename)
+ return _handle_pdf(filename, doi)
raise Exception('Unsupported file type ' + str(mtype))