From: John Kitchin Date: Fri, 30 Jan 2015 16:38:26 +0000 (-0500) Subject: try making it more robust to open doi in browser if we cannot get json metadata. X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=commitdiff_plain;h=3ae4b0fa73f72bffe4de1dd8b50b5dc2cc1ecd52;hp=37248aa86346505fbf10d36fbb872527936c91c7 try making it more robust to open doi in browser if we cannot get json metadata. --- diff --git a/doi-utils.org b/doi-utils.org index a96fc93..fda747d 100644 --- a/doi-utils.org +++ b/doi-utils.org @@ -411,7 +411,7 @@ I [[http://homepages.see.leeds.ac.uk/~eeaol/notes/2013/02/doi-metadata/][found]] #+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) @@ -420,8 +420,11 @@ I [[http://homepages.see.leeds.ac.uk/~eeaol/notes/2013/02/doi-metadata/][found]] (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: