Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Created March 30, 2013 20:54
Show Gist options
  • Select an option

  • Save Idorobots/5278294 to your computer and use it in GitHub Desktop.

Select an option

Save Idorobots/5278294 to your computer and use it in GitHub Desktop.
Export your RSS feeds from Google Reader into Emacs News Ticker compatible format.
(require 'xml)
(defun assoc-or-error (what where &optional err-string)
(or (assoc what where)
(error (or err-string "Suddenly errors! Thousands of them!"))))
(defun google-reader-to-newsticker (filename)
"Parses google-reader subscription XML and returns newsticker compatible feed alist."
(with-temp-buffer
(insert-file-contents filename)
(let* ((opml (assoc-or-error 'opml
(xml-parse-region (point-min) (point-max))
"Not a valid feed XML!"))
(body (assoc-or-error 'body
opml
"Not a valid feed XML!"))
(outlines (delq nil
(map 'list
(lambda (element)
(and (consp element)
(equal (car element) 'outline)
element))
body)))
(alist (map 'list
(lambda (outline)
(let ((title (assoc-or-error 'title
outline
"No title in an outline - malformed feed XML?"))
(feed (assoc-or-error 'xmlUrl
outline
"No feed link in an outline - check your feed XML!")))
(list (cdr title) (cdr feed))))
(map 'list
#'cadr
outlines))))
alist)))
@Idorobots
Copy link
Author

Weird, on my end it seems to be working and no parentheses are missing.
On a side note, a probably better solution is to use the builtin Newsticker importer - newsticker-opml-import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment