Last active
April 10, 2016 17:18
-
-
Save jorgenschaefer/cd9cbc05864e6a8f037f018c8e7a656f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'json) | |
(require 'subr-x) | |
(defun fix-string (s) | |
(string-join | |
(delq nil (mapcar (lambda (ch) | |
(encode-coding-char ch 'utf-8 'unicode)) | |
s)))) | |
(with-current-buffer (url-retrieve-synchronously | |
"http://gnufans.net/~fsbot/data/botbbdb") | |
(goto-char (point-min)) | |
(re-search-forward "^$") | |
(let ((entries nil)) | |
(condition-case err | |
(while t | |
(let* ((entry (read (current-buffer))) | |
(name (fix-string (elt entry 0))) | |
(data (elt entry 7)) | |
(timestamp (cdr (assq 'timestamp data))) | |
(notes (let ((n (cdr (assq 'notes data)))) | |
(if (stringp n) | |
n | |
(format "%s" n)))) | |
(parsed (mapcar 'fix-string (read notes)))) | |
(push `((name . ,name) | |
(timestamp . ,timestamp) | |
(data . ,parsed)) | |
entries))) | |
(end-of-file | |
nil)) | |
(write-region (json-encode entries) | |
nil | |
"/tmp/fsbot.json"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment