Created
October 23, 2012 21:27
-
-
Save bo0ts/3941705 to your computer and use it in GitHub Desktop.
Query IMDB and parse the result into org-mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'url) | |
(defun get-and-parse-json (url) | |
(interactive) | |
(with-current-buffer (url-retrieve-synchronously url) | |
(goto-char (point-min)) | |
(re-search-forward "^$") | |
(json-read))) | |
(defun get-movie-json (title &optional year) | |
(let ((url (concat "http://omdbapi.com/?t=" (url-hexify-string title)))) | |
(if (consp year) | |
(get-and-parse-json (concat url "&y=" (number-to-string year))) | |
(get-and-parse-json url)))) | |
(defun org-from-imdb-json (jsonmovie) | |
(concat "* [[imdb:" (cdr (assoc 'imdbID jsonmovie)) "][" (cdr (assoc 'Title jsonmovie)) "]]\n" | |
":PROPERTIES:\n" | |
":Director: " (cdr (assoc 'Director jsonmovie)) "\n" | |
":Year: " (cdr (assoc 'Year jsonmovie)) "\n" | |
":Actors: " (cdr (assoc 'Genre jsonmovie)) "\n" | |
":Genre: " (cdr (assoc 'Actors jsonmovie)) "\n" | |
":Plot: " (cdr (assoc 'Plot jsonmovie)) | |
":END:\n" | |
"[[" (cdr (assoc 'Poster jsonmovie)) "]]" | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment