Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bb
- (require '[clojure.pprint :as pp]) ;'
- (require '[babashka.http-client :as http]) ;'
- (require '[babashka.process :refer [shell process exec]]) ;'
- (defn is-faaag? [thread]
- "Return true if the thread looks like a Lisp General thread."
- (and (thread "sub")
- (or (re-matches #".*(/faaag/).*" (thread "sub")))))
- (defn thread-url [board no]
- (str "https://boards.4chan.org/" board "/thread/" no))
- (def catalog-response (http/get "https://a.4cdn.org/jp/catalog.json"))
- (def catalog (json/parse-string (catalog-response :body)))
- (def all-threads (flatten (map (fn [p] (get p "threads")) catalog)))
- (def jp-faaag (first (filter is-faaag? all-threads)))
- (if jp-faaag (shell "xdg-open" (thread-url "jp" (jp-faaag "no"))))
Advertisement
Add Comment
Please, Sign In to add comment