279de613dd93

Wrap the http requests to apple.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 05 Oct 2011 22:19:48 -0400
parents a7d0d997f520
children 295b300cdddb
branches/tags (none)
files src/newseasons/itunes.clj src/newseasons/loops/refresh.clj

Changes

--- a/src/newseasons/itunes.clj	Wed Oct 05 22:05:24 2011 -0400
+++ b/src/newseasons/itunes.clj	Wed Oct 05 22:19:48 2011 -0400
@@ -5,9 +5,12 @@
 
 
 (defn itunes-search [params]
-  ((parse-string (:body (client/get "http://itunes.apple.com/search"
-                                    {:query-params params})))
-     "results"))
+  (try
+    ((parse-string (:body (client/get "http://itunes.apple.com/search"
+                                      {:query-params params})))
+       "results")
+    (catch java.lang.Exception e
+      (println "Failed request to " (:url (.data e))))))
 
 (defn itunes-search-show [query]
   (itunes-search {"term" query
@@ -17,10 +20,13 @@
 
 
 (defn itunes-lookup [field id entity]
-  ((parse-string (:body (client/get "http://itunes.apple.com/lookup"
-                                    {:query-params {field id
-                                                    "entity" entity}})))
-     "results"))
+  (try
+    ((parse-string (:body (client/get "http://itunes.apple.com/lookup"
+                                      {:query-params {field id
+                                                      "entity" entity}})))
+       "results")
+    (catch java.lang.Exception e
+      (println "Failed request to " (:url (.data e))))))
 
 (defn itunes-lookup-seasons [id]
   (let [results (itunes-lookup "id" id "tvSeason")]
--- a/src/newseasons/loops/refresh.clj	Wed Oct 05 22:05:24 2011 -0400
+++ b/src/newseasons/loops/refresh.clj	Wed Oct 05 22:19:48 2011 -0400
@@ -47,7 +47,7 @@
     (Thread/sleep 10000)))
 
 (defn- refresh []
-  (println "")
+  (println "\n\n")
   (println "Refreshing Shows")
   (println "----------------")
   (Thread/sleep 20000)