You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
48 lines
1.4 KiB
(in-package #:lolicore)
|
|
|
|
(defparameter *boorus* '())
|
|
|
|
(add-booru :name 'lolibooru
|
|
:url "https://lolibooru.moe/post/index.json?tags=rating:~a+-3dcg+-rape&limit=1&page=~a"
|
|
:rating-posts (make-ratings (74000 53000 92000)))
|
|
|
|
(add-booru :name 'gelbooru
|
|
:url "https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&tags=rating:~a&limit=1&pid=~a"
|
|
:rating-posts (make-ratings (20000 20000 20000))
|
|
:rating-table ratings-full-words)
|
|
|
|
(defun loli-link (rating)
|
|
(let ((booru (cl-rng:within *boorus*)))
|
|
(format nil (url booru)
|
|
(get-rating booru rating)
|
|
(cl-rng:crandom :limit (get-posts booru rating) :transform 'floor))))
|
|
|
|
(defun loli-json (rating)
|
|
(car (jsown:parse (dex:get (loli-link rating)))))
|
|
|
|
(defun loli-data (json &key tags file-url
|
|
&aux (lst '()))
|
|
(when tags
|
|
(push (add-data :tags "tags" json) lst))
|
|
(when file-url
|
|
(push (add-data :file-url "file_url" json) lst))
|
|
lst)
|
|
|
|
(defun loli-get (rating)
|
|
"Identical to calling `loli-data' with all keys"
|
|
(loli-data (loli-json rating)
|
|
:tags t
|
|
:file-url t))
|
|
|
|
(defun based-loli (url)
|
|
"I got told off for trying to inline this."
|
|
(declare (type string url))
|
|
(str "data:image/jpeg;base64," (qbase64:encode-bytes (dex:get url))))
|
|
|
|
(export '(loli-link
|
|
based-loli
|
|
loli-data
|
|
loli-json
|
|
loli-get
|
|
*boorus*))
|