aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tau/api/comments.clj
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-17 13:17:40 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-17 13:17:40 +0100
commit81f03c0b449bec1fa60cf2936bfc3f66a5ad58c1 (patch)
treea2a7aa01f61dd71b511dd3729a9f4b28c35b531f /src/backend/tau/api/comments.clj
parent5e995881dd0c431ae63b1a50c2d03e59962241f1 (diff)
chore: Rename project
Diffstat (limited to 'src/backend/tau/api/comments.clj')
-rw-r--r--src/backend/tau/api/comments.clj45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/backend/tau/api/comments.clj b/src/backend/tau/api/comments.clj
deleted file mode 100644
index c0891ea..0000000
--- a/src/backend/tau/api/comments.clj
+++ /dev/null
@@ -1,45 +0,0 @@
-(ns tau.api.comments
- (: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.ListExtractor
- org.schabi.newpipe.extractor.comments.CommentsInfoItem
- org.schabi.newpipe.extractor.comments.CommentsInfo))
-
-(defn get-comment-item
- [item extractor]
- {:id (.getCommentId item)
- :text (.getCommentText item)
- :uploader-name (.getUploaderName item)
- :uploader-avatar (.getUploaderAvatarUrl item)
- :uploader-url (.getUploaderUrl item)
- :uploader-verified? (.isUploaderVerified item)
- :upload-date (.getTextualUploadDate item)
- :like-count (when-not (= (.getLikeCount item) -1) (.getLikeCount item))
- :reply-count (when-not (= (.getReplyCount item) -1) (.getReplyCount item))
- :hearted-by-uploader? (.isHeartedByUploader item)
- :pinned? (.isPinned item)
- :stream-position (when-not (= (.getStreamPosition item) -1) (.getStreamPosition item))
- :replies (when (.getReplies item)
- (if extractor
- (let [comments-page (.getPage extractor (.getReplies item))]
- {:next-page (when (.hasNextPage comments-page) (j/from-java (.getNextPage comments-page)))
- :items (map #(get-comment-item % extractor) (.getItems comments-page))})
- (j/from-java (.getReplies item))))})
-
-(defn get-comments
- ([url]
- (let [info (CommentsInfo/getInfo (url-decode url))
- extractor (.getCommentsExtractor info)]
- {:comments (map #(get-comment-item % extractor) (.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-decode url) (Page. (url-decode page-url)))]
- {:comments (map #(get-comment-item % nil) (.getItems info))
- :next-page (j/from-java (.getNextPage info))
- :disabled? false})))