summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imgreplacer.clj5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/imgreplacer.clj b/src/imgreplacer.clj
index 4963e02..fe316c7 100644
--- a/src/imgreplacer.clj
+++ b/src/imgreplacer.clj
@@ -32,11 +32,14 @@
(reduce (fn [s [k v]] (.replaceAll s k v))
string replacements))
+(defn image-name [url]
+ (format "%s-%s" (System/currentTimeMillis) (last (.split url "/"))))
+
(defn mirror-image [url]
(println "fetching" url)
(let [bytes (to-byte-array (.openStream (URL. url)))
date (today)
- fname (last (.split url "/"))
+ fname (image-name url)
file (File. (file-path date fname))
img (ImageIO/read (ByteArrayInputStream. bytes))]
(make-parents file)