Guest User

jp-faaag.clj

a guest
Feb 2nd, 2025
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Clojure 0.75 KB | Source Code | 0 0
  1. #!/usr/bin/env bb
  2. (require '[clojure.pprint :as pp])         ;'
  3. (require '[babashka.http-client :as http]) ;'
  4. (require '[babashka.process :refer [shell process exec]]) ;'
  5.  
  6. (defn is-faaag? [thread]
  7.   "Return true if the thread looks like a Lisp General thread."
  8.   (and (thread "sub")
  9.        (or (re-matches #".*(/faaag/).*" (thread "sub")))))
  10.  
  11. (defn thread-url [board no]
  12.   (str "https://boards.4chan.org/" board "/thread/" no))
  13.  
  14. (def catalog-response (http/get "https://a.4cdn.org/jp/catalog.json"))
  15. (def catalog (json/parse-string (catalog-response :body)))
  16. (def all-threads (flatten (map (fn [p] (get p "threads")) catalog)))
  17. (def jp-faaag (first (filter is-faaag? all-threads)))
  18.  
  19. (if jp-faaag (shell "xdg-open" (thread-url "jp" (jp-faaag "no"))))
  20.  
Advertisement
Add Comment
Please, Sign In to add comment