From 94d98e34027c37e5098fadd45bb1e647e4e5733a Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Mon, 26 Jul 2010 19:52:54 +0530 Subject: [PATCH] Added examples --- src/clj_lastfm/core.clj | 4 +++- src/clj_lastfm/examples.clj | 9 +++++++++ src/log4j.properties | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/clj_lastfm/examples.clj diff --git a/src/clj_lastfm/core.clj b/src/clj_lastfm/core.clj index 1e45282..1747468 100644 --- a/src/clj_lastfm/core.clj +++ b/src/clj_lastfm/core.clj @@ -26,6 +26,8 @@ (defvar- attr-kw (keyword "@attr")) +(defvar- text-kw (keyword "#text")) + (defn- safe-parse-int [n] (if (nil? n) nil @@ -428,7 +430,7 @@ :mbid (-> data :artist :mbid)) :playcount (-> data :playcount safe-parse-int) :listeners (-> data :listeners safe-parse-int) - :streamable (-> data :streamable :#text str-1?) + :streamable (-> data :streamable text-kw str-1?) :streamable-full (-> data :streamable :fulltrack str-1?))) (defvar- parse-artist-toptracks diff --git a/src/clj_lastfm/examples.clj b/src/clj_lastfm/examples.clj new file mode 100644 index 0000000..4f0ff81 --- /dev/null +++ b/src/clj_lastfm/examples.clj @@ -0,0 +1,9 @@ +(ns clj-lastfm.examples + (:use [clj-lastfm.core])) + +(defn- indexed [s] (map vector (iterate inc 1) s)) + +(defn print-topten-tracks [artist-name] + (doseq [[idx name] + (->> artist-name artist-toptracks (take 10) (map :name) indexed)] + (println (format "%s. %s" idx name)))) \ No newline at end of file diff --git a/src/log4j.properties b/src/log4j.properties index 16cb9e4..6b2bc3f 100644 --- a/src/log4j.properties +++ b/src/log4j.properties @@ -1,6 +1,6 @@ # Based on the example properties given at http://logging.apache.org/log4j/1.2/manual.html # Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=INFO,A1 +log4j.rootLogger=ERROR,A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender