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.
52 lines
1.6 KiB
52 lines
1.6 KiB
(in-package #:lolicore)
|
|
|
|
(defparameter *boorus* '())
|
|
|
|
(defmacro make-ratings ((safe questionable explicit))
|
|
`(quote (("s" . ,safe)
|
|
("q" . ,questionable)
|
|
("e" . ,explicit))))
|
|
|
|
(defvar ratings-full-words '(("s" . "safe")
|
|
("q" . "questionable")
|
|
("e" . "explicit")))
|
|
|
|
(defclass booru ()
|
|
((name
|
|
:initarg :name
|
|
:reader name)
|
|
(url
|
|
:initarg :url
|
|
:reader url)
|
|
(rating-table
|
|
:initarg :rating-table
|
|
:reader rating-table)
|
|
(rating-posts
|
|
:initarg :rating-posts
|
|
:reader rating-posts))
|
|
(:default-initargs
|
|
:name (error "Need a name")
|
|
:url (error "Need a URL")
|
|
:rating-table '(("s" . "s")
|
|
("q" . "q")
|
|
("e" . "e"))
|
|
:rating-posts (error "Need number of posts per rating")))
|
|
|
|
(defmethod get-rating ((obj booru) rating)
|
|
"Gets the `rating' from `rating-table' of `booru'"
|
|
(cdr (assoc rating (rating-table obj) :test 'string=)))
|
|
|
|
(defmethod get-posts ((obj booru) rating)
|
|
"Gets the max posts for `rating' for `booru'"
|
|
(cdr (assoc rating (rating-posts obj) :test 'string=)))
|
|
|
|
;; Built-in 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={loli ~ child}+rating:~a&limit=1&pid=~a"
|
|
:rating-posts (make-ratings (20000 20000 20000))
|
|
:rating-table ratings-full-words)
|