aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tau/api/comment.clj
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2022-12-29 01:53:08 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2022-12-29 01:53:08 +0100
commitdfcc61063822dfb0fe699896da312249e93d5439 (patch)
treec1dc29de45cfe4ae67f104510dc3c4b6d858aa46 /src/backend/tau/api/comment.clj
parent6382ec24c5bbbf93ced1e587103a52b3a63e6045 (diff)
feat(backend): Remove records and simplify API
Diffstat (limited to 'src/backend/tau/api/comment.clj')
-rw-r--r--src/backend/tau/api/comment.clj47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/backend/tau/api/comment.clj b/src/backend/tau/api/comment.clj
deleted file mode 100644
index 956090e..0000000
--- a/src/backend/tau/api/comment.clj
+++ /dev/null
@@ -1,47 +0,0 @@
-(ns tau.api.comment
- (:require
- [clojure.java.data :as j]
- [ring.util.codec :refer [url-decode]])
- (:import
- org.schabi.newpipe.extractor.NewPipe
- org.schabi.newpipe.extractor.Page
- org.schabi.newpipe.extractor.comments.CommentsInfoItem
- org.schabi.newpipe.extractor.comments.CommentsInfo))
-
-(defrecord CommentsPage
- [next-page disabled? comments])
-
-(defrecord Comment
- [id text upload-name upload-avatar upload-date upload-url
- upload-verified? like-count hearted-by-upload? pinned? replies])
-
-(defn get-result
- [comment]
- (map->Comment
- {:id (.getCommentId comment)
- :text (.getCommentText comment)
- :upload-name (.getUploaderName comment)
- :upload-avatar (.getUploaderAvatarUrl comment)
- :upload-date (.getTextualUploadDate comment)
- :upload-url (.getUploaderUrl comment)
- :upload-verified? (.isUploaderVerified comment)
- :like-count (.getLikeCount comment)
- :hearted-by-upload? (.isHeartedByUploader comment)
- :pinned? (.isPinned comment)
- :replies (when (.getReplies comment)
- (j/from-java (.getReplies comment)))}))
-
-(defn get-info
- ([url]
- (let [info (CommentsInfo/getInfo (url-decode url))]
- (map->CommentsPage
- {:comments (map #(get-result %) (.getRelatedItems info))
- :next-page (j/from-java (.getNextPage info))
- :disabled? (.isCommentsDisabled info)})))
- ([url page-url]
- (let [service (NewPipe/getServiceByUrl (url-decode url))
- info (CommentsInfo/getMoreItems service url (Page. (url-decode page-url)))]
- (map->CommentsPage
- {:comments (map #(get-result %) (.getItems info))
- :next-page (j/from-java (.getNextPage info))
- :disabled? false}))))