Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pbalduino/ccb
base: 0abd5446e2
...
head fork: pbalduino/ccb
compare: 6818d86c1d
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
9 09/grokpodcast/.gitignore
@@ -0,0 +1,9 @@
+/target
+/classes
+/checkouts
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+/.lein-*
+/.nrepl-port
View
4 09/grokpodcast/project.clj
@@ -0,0 +1,4 @@
+(defproject grokpodcast "0.1.0-SNAPSHOT"
+ :dependencies [[org.clojure/clojure "1.5.1"]
+ [enlive "1.1.5"]]
+ :main grokpodcast.core)
View
42 09/grokpodcast/src/grokpodcast/core.clj
@@ -0,0 +1,42 @@
+(ns grokpodcast.core
+ (:require [clojure.java.io :as io]
+ [clojure.pprint :as pp]
+ [clojure.string :as str]
+ [net.cgrand.enlive-html :as en])
+ (:import [java.net URL]))
+
+(def file-dir "C:\\Documents and Settings\\pbalduino\\Meus documentos\\grokpodcast\\")
+
+(defn- get-archive [url]
+ (map
+ #(str "http://www.grokpodcast.com" ((% :attrs) :href))
+ (-> url
+ URL.
+ en/html-resource
+ (en/select [:section#episode-archive :a]))))
+
+(defn- get-file-link [episode-url]
+ (let [link (-> episode-url
+ URL.
+ en/html-resource
+ (en/select [:section#podcast-infos :a])
+ first)]
+ ((link :attrs) :href)))
+
+(defn- download-file [episode-url]
+ (let [link (get-file-link episode-url)
+ filename (-> link
+ (str/split #"/")
+ last)
+ filepath (str file-dir filename)]
+ (when-not (. (io/file filepath) exists)
+ (with-open [in (io/input-stream link)
+ out (io/output-stream (str file-dir filename))]
+ (println "Baixando" filename)
+ (io/copy in out)
+ (println " Concluido" filename)))))
+
+(defn -main [& args]
+ (doall
+ (pmap download-file (get-archive "http://www.grokpodcast.com/arquivo/")))
+ (shutdown-agents))

No commit comments for this range

Something went wrong with that request. Please try again.