                  genres
                  image])
 
-(def finnish-date-format (formatter "dd.MM.yyyy"))
+(defn group-by-genre [shows]
+  (group-by
+    (fn [{genres :genres}]
+      (condp some genres
+        #{"Komedia"} :comedy
+        #{"Draama"} :drama
+        #{"Toiminta"} :action
+        :other))
+    shows))
 
-(def url (str "http://finnkino.fi/xml/Schedule/?area=1002&dt="
-              (unparse finnish-date-format (now))))
-
-(def movies (zip/xml-zip (xml/parse url)))
-
-(defn get-shows [xz] 
+(defn parse-shows [xz] 
   (for [show (xml-> xz :Shows :Show)]
     (Show.
       (xml1-> show :OriginalTitle text)

      (into #{} (split (xml1-> show :Genres text) #", "))
      (xml1-> show :Images :EventLargeImagePortrait text))))

; To parse the starting times...
; (map (fn [{time :time}] (unparse (formatters :hour-minute) (parse time)))   (get-shows movies))
(defroutes handler
  (GET "/" []
    (views/shows (get-shows movies))))

(run-jetty handler {:port 8080 :join? false})



(defn list-shows [shows]
  [:table
    (for [day shows]
      [:tr
        [:td (:time (first (:comedy day)))]
        [:td (map :title (:comedy day))]])])

(defn shows [shows]
  (layout (list-shows shows)))
