Steve Losh avatar Steve Losh committed a7d0d99

Add emailing.

Comments (0)

Files changed (1)

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 "")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.