Last active
December 17, 2015 11:49
-
-
Save jackrusher/5605471 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
(ns tumblr-backup.core | |
(:use [clojure.xml :as xml])) | |
(defn build-tumblr-url [start howmany] | |
(format "http://blog.jackrusher.com/api/read/?start=%d&num=%d" start howmany)) | |
(defn get-post-count [] | |
(read-string (-> (xml/parse (build-tumblr-url 0 0)) :content second :attrs :total))) | |
(defn spit-post [post] | |
(let [post (-> post :content second :content first) | |
attrs (:attrs post) | |
filename (str (:unix-timestamp attrs) "-" (:slug attrs) ".xml")] | |
(println filename) | |
(spit filename post))) | |
(defn backup-tumblr [] | |
(doseq [post-num (range (get-post-count))] | |
(spit-post (xml/parse (build-tumblr-url post-num 1))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment