summaryrefslogtreecommitdiffstats
path: root/.scripts/getbib
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-07-03 10:55:55 -0400
committerLuke Smith <luke@lukesmith.xyz>2018-07-03 10:55:55 -0400
commite90ccb573cc5aa75e9aff991bde886e9788c8a98 (patch)
treeb36c38fe80706df57e186e039951ba3875ece1fb /.scripts/getbib
parent542c50579637b43915a744d358747b9bed0d3867 (diff)
downloadeibhear-e90ccb573cc5aa75e9aff991bde886e9788c8a98.tar.gz
eibhear-e90ccb573cc5aa75e9aff991bde886e9788c8a98.tar.zst
eibhear-e90ccb573cc5aa75e9aff991bde886e9788c8a98.zip
getbib script added
Diffstat (limited to '.scripts/getbib')
-rwxr-xr-x.scripts/getbib15
1 files changed, 15 insertions, 0 deletions
diff --git a/.scripts/getbib b/.scripts/getbib
new file mode 100755
index 0000000..0ea30d3
--- /dev/null
+++ b/.scripts/getbib
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Give this script a .pdf and it will attempt
+# to return a proper .bib citation via doi.
+# Internet connection required.
+
+# Get the doi from metadata, if not possible, get
+# doi from pdftotext output, if not possible, exit.
+doi=$(pdfinfo "$1" | grep -o doi:.*) ||
+ doi=$(pdftotext "$1" - | grep -o doi.* -m 1) ||
+ exit 1
+
+# Check crossref.org for the bib citation.
+curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\n" |
+ sed -e "/^[^\(\t\|@\|}\)]/d"