#+BEGIN_SRC emacs-lisp :tangle doi-utils.el
(defun doi-utils-get-json-metadata (doi)
-
+ "Try to get json metadata for DOI. Open the DOI in a browser if we do not get it."
(let ((url-request-method "GET")
(url-mime-accept-string "application/citeproc+json")
(json-object-type 'plist)
(url-retrieve-synchronously
(concat "http://dx.doi.org/" doi))
(setq json-data (buffer-substring url-http-end-of-headers (point-max)))
- (message "%s" json-data)
- (json-read-from-string json-data))))
+ (if (string-match "Resource not found" json-data)
+ (progn
+ (browse-url (concat "http://dx.doi.org/" doi))
+ (error "Resource not found. Opening website."))
+ (json-read-from-string json-data)))))
#+END_SRC
#+RESULTS: