Commits

Steve Losh  committed a7d0d99

Add emailing.

  • Participants
  • Parent commits 9a3a49a

Comments (0)

Files changed (1)

File src/newseasons/loops/refresh.clj

 (ns newseasons.loops.refresh
+  (:use [postmark.core :only (postmark)])
+  (:use [newseasons.loops.templates.email :only (new-season)])
   (:use [newseasons.settings :only (postmark-api-key)])
   (:require [newseasons.models.shows :as shows])
   (:require [newseasons.itunes :as itunes]))
 
+(def pm (postmark postmark-api-key "newseasons@stevelosh.com"))
 
 ; Dammit, Clojure.
 (defn- gt [a b]
 
 
 (defn- notify [show email]
-  (println "    to:" email)
-  (println "        Sweet, a new season of" (:title show) "has been released!")
-  (println "        New season:" (:latest show)))
+  (let [body (new-season email show)]
+    (println (pm {:to email
+                  :subject (str "[New Seasons] A new season of "
+                                (:title show)
+                                " has hit iTunes!")
+                  :text body
+                  :tag "newseasons"}))))
 
 (defn- notify-all [show-id]
   (let [show (shows/show-get show-id)
 (defn- refresh-show [id]
   (println "  refreshing" id)
   (let [show (itunes/itunes-lookup-seasons id)]
-    (if show
-      (do
-        (check-and-notify show)
-        (shows/store-raw-show show)
-        (println (show "artistName") "/" (show "collectionName")))
-      (println "(unknown)"))
-    (Thread/sleep 4000)))
+    (when show
+      (check-and-notify show)
+      (shows/store-raw-show show))
+    (Thread/sleep 10000)))
 
 (defn- refresh []
   (println "")