# HG changeset patch # User Steve Losh # Date 1317866724 14400 # Node ID a7d0d997f5206ec5ffe987e360a6c7d85eda48f0 # Parent 9a3a49acb6e057a00e6e933d40769fbf36679552 Add emailing. diff -r 9a3a49acb6e0 -r a7d0d997f520 src/newseasons/loops/refresh.clj --- a/src/newseasons/loops/refresh.clj Wed Oct 05 21:54:22 2011 -0400 +++ b/src/newseasons/loops/refresh.clj Wed Oct 05 22:05:24 2011 -0400 @@ -1,8 +1,11 @@ (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] @@ -13,9 +16,13 @@ (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) @@ -34,13 +41,10 @@ (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 "")