refactor shaarli so tag isn't hardcoded
This commit is contained in:
parent
424b1683b8
commit
8b9381d5e1
|
@ -40,18 +40,18 @@
|
||||||
|
|
||||||
(def token (generate-token (System/getenv "SHAARLI_TOKEN")))
|
(def token (generate-token (System/getenv "SHAARLI_TOKEN")))
|
||||||
|
|
||||||
(defn shaarli-request [limit offset]
|
(defn shaarli-request [tag limit offset]
|
||||||
(-> (curl/get (str "http://links.mossnet.lan/api/v1/links?searchtags=music&limit=" limit "&offset=" offset) {:headers {"Authorization" (str "Bearer " token)}})
|
(-> (curl/get (str "http://links.mossnet.lan/api/v1/links?searchtags=" tag "&limit=" limit "&offset=" offset) {:headers {"Authorization" (str "Bearer " token)}})
|
||||||
(:body)
|
(:body)
|
||||||
(json/parse-string true)))
|
(json/parse-string true)))
|
||||||
|
|
||||||
(defn get-all-shaarli-data
|
(defn get-all-shaarli-music-data
|
||||||
[]
|
[]
|
||||||
(shaarli-request "all" 0))
|
(shaarli-request "music" "all" 0))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(shaarli-request 100 0)
|
(shaarli-request "" 20 0)
|
||||||
(count (get-all-shaarli-data))
|
(count (get-all-shaarli-music-data))
|
||||||
(url-filterer {:url "bandcamp"} "bandcamp")
|
(url-filterer {:url "bandcamp"} "bandcamp")
|
||||||
(filter (fn [x] (.contains (get x :url) "bandcamp")) [{:url "bandcamp"}])
|
(filter (fn [x] (.contains (get x :url) "bandcamp")) [{:url "bandcamp"}])
|
||||||
(println "somestring")
|
(println "somestring")
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
(ns dhyan.main
|
(ns dhyan.main
|
||||||
(:require [dhyan.connections.shaarli :as shaarli]
|
(:require [dhyan.connections.shaarli :as shaarli]
|
||||||
[clojure.java.shell :refer [sh]]
|
|
||||||
[dhyan.connections.matrix :as matrix]))
|
[dhyan.connections.matrix :as matrix]))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& _args]
|
[& _args]
|
||||||
(matrix/setup)
|
(matrix/setup)
|
||||||
(let [shaarli-data (shaarli/get-all-shaarli-data)
|
(let [shaarli-data (shaarli/get-all-shaarli-music-data)
|
||||||
; filter to bandcamp (and maybe others?)
|
; filter to bandcamp (and maybe others?)
|
||||||
filtered-shaarli-data (shaarli/url-filterer shaarli-data "bandcamp")
|
filtered-shaarli-data (shaarli/url-filterer shaarli-data "bandcamp")
|
||||||
album-of-the-day (->> filtered-shaarli-data
|
album-of-the-day (->> filtered-shaarli-data
|
||||||
|
|
Loading…
Reference in a new issue