diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2023-01-17 13:17:40 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2023-01-17 13:17:40 +0100 |
commit | 81f03c0b449bec1fa60cf2936bfc3f66a5ad58c1 (patch) | |
tree | a2a7aa01f61dd71b511dd3729a9f4b28c35b531f /src/backend/tau/api | |
parent | 5e995881dd0c431ae63b1a50c2d03e59962241f1 (diff) |
chore: Rename project
Diffstat (limited to 'src/backend/tau/api')
-rw-r--r-- | src/backend/tau/api/channels.clj | 29 | ||||
-rw-r--r-- | src/backend/tau/api/comments.clj | 45 | ||||
-rw-r--r-- | src/backend/tau/api/items.clj | 47 | ||||
-rw-r--r-- | src/backend/tau/api/playlists.clj | 31 | ||||
-rw-r--r-- | src/backend/tau/api/services.clj | 79 | ||||
-rw-r--r-- | src/backend/tau/api/streams.clj | 36 |
6 files changed, 0 insertions, 267 deletions
diff --git a/src/backend/tau/api/channels.clj b/src/backend/tau/api/channels.clj deleted file mode 100644 index 2c82767..0000000 --- a/src/backend/tau/api/channels.clj +++ /dev/null @@ -1,29 +0,0 @@ -(ns tau.api.channels - (:require - [clojure.java.data :as j] - [ring.util.codec :refer [url-decode]] - [tau.api.items :as items]) - (:import - org.schabi.newpipe.extractor.channel.ChannelInfo - org.schabi.newpipe.extractor.NewPipe - org.schabi.newpipe.extractor.Page)) - -(defn get-channel - ([url] - (let [info (ChannelInfo/getInfo (url-decode url))] - {:id (.getId info) - :name (.getName info) - :verified? (.isVerified info) - :banner (.getBannerUrl info) - :avatar (.getAvatarUrl info) - :description (.getDescription info) - :subscriber-count (when-not (= (.getSubscriberCount info) -1) (.getSubscriberCount info)) - :donation-links (.getDonationLinks info) - :next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getRelatedItems info)) - :service-id (.getServiceId info)})) - ([url page-url] - (let [service (NewPipe/getServiceByUrl (url-decode url)) - info (ChannelInfo/getMoreItems service (url-decode url) (Page. (url-decode page-url)))] - {:related-streams (items/get-items (.getItems info)) - :next-page (j/from-java (.getNextPage info))}))) 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}))) diff --git a/src/backend/tau/api/items.clj b/src/backend/tau/api/items.clj deleted file mode 100644 index 676af3e..0000000 --- a/src/backend/tau/api/items.clj +++ /dev/null @@ -1,47 +0,0 @@ -(ns tau.api.items) - -(defn get-stream-item - [stream] - {:type :stream - :url (.getUrl stream) - :name (.getName stream) - :thumbnail-url (.getThumbnailUrl stream) - :uploader-name (.getUploaderName stream) - :uploader-url (.getUploaderUrl stream) - :uploader-avatar (.getUploaderAvatarUrl stream) - :upload-date (.getTextualUploadDate stream) - :short-description (.getShortDescription stream) - :duration (.getDuration stream) - :view-count (when-not (= (.getViewCount stream) -1) (.getViewCount stream)) - :uploaded (if (.getUploadDate stream) - (.. stream (getUploadDate) (offsetDateTime) (toInstant) (toEpochMilli)) - false) - :verified? (.isUploaderVerified stream)}) - -(defn get-channel-item - [channel] - {:type :channel - :url (.getUrl channel) - :name (.getName channel) - :thumbnail-url (.getThumbnailUrl channel) - :description (.getDescription channel) - :subscriber-count (when-not (= (.getSubscriberCount channel) -1) (.getSubscriberCount channel)) - :stream-count (when-not (= (.getStreamCount channel) -1) (.getStreamCount channel)) - :verified? (.isVerified channel)}) - -(defn get-playlist-item - [playlist] - {:type :playlist - :url (.getUrl playlist) - :name (.getName playlist) - :thumbnail-url (.getThumbnailUrl playlist) - :uploader-name (.getUploaderName playlist) - :stream-count (when-not (= (.getStreamCount playlist) -1) (.getStreamCount playlist))}) - -(defn get-items - [items] - (map #(case (.name (.getInfoType %)) - "STREAM" (get-stream-item %) - "CHANNEL" (get-channel-item %) - "PLAYLIST" (get-playlist-item %)) - items)) diff --git a/src/backend/tau/api/playlists.clj b/src/backend/tau/api/playlists.clj deleted file mode 100644 index 5520d2b..0000000 --- a/src/backend/tau/api/playlists.clj +++ /dev/null @@ -1,31 +0,0 @@ -(ns tau.api.playlists - (:require - [clojure.java.data :as j] - [ring.util.codec :refer [url-decode]] - [tau.api.items :as items]) - (:import - org.schabi.newpipe.extractor.playlist.PlaylistInfo - org.schabi.newpipe.extractor.Page - org.schabi.newpipe.extractor.NewPipe)) - -(defn get-playlist - ([url] - (let [service (NewPipe/getServiceByUrl (url-decode url)) - info (PlaylistInfo/getInfo service (url-decode url))] - {:id (.getId info) - :name (.getName info) - :playlist-type (j/from-java (.getPlaylistType info)) - :thumbnail-url (.getThumbnailUrl info) - :banner-url (.getBannerUrl info) - :uploader-name (.getUploaderName info) - :uploader-url (.getUploaderUrl info) - :uploader-avatar (.getUploaderAvatarUrl info) - :stream-count (.getStreamCount info) - :next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getRelatedItems info)) - :service-id (.getServiceId info)})) - ([url page-url] - (let [service (NewPipe/getServiceByUrl (url-decode url)) - info (PlaylistInfo/getMoreItems service url (Page. (url-decode page-url)))] - {:next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getItems info))}))) diff --git a/src/backend/tau/api/services.clj b/src/backend/tau/api/services.clj deleted file mode 100644 index 8b9638f..0000000 --- a/src/backend/tau/api/services.clj +++ /dev/null @@ -1,79 +0,0 @@ -(ns tau.api.services - (:require - [clojure.java.data :as j] - [ring.util.codec :refer [url-encode url-decode]] - [tau.api.items :as items]) - (:import - org.schabi.newpipe.extractor.kiosk.KioskInfo - org.schabi.newpipe.extractor.kiosk.KioskList - org.schabi.newpipe.extractor.InfoItem - org.schabi.newpipe.extractor.NewPipe - org.schabi.newpipe.extractor.Page - org.schabi.newpipe.extractor.StreamingService - org.schabi.newpipe.extractor.search.SearchInfo)) - -(defn search - ([service-id query content-filters sort-filter] - (let [service (NewPipe/getService service-id) - query-handler (.. service - (getSearchQHFactory) - (fromQuery query (or content-filters '()) (or sort-filter ""))) - info (SearchInfo/getInfo service query-handler)] - {:items (items/get-items (.getRelatedItems info)) - :next-page (j/from-java (.getNextPage info)) - :search-suggestion (.getSearchSuggestion info) - :corrected-search? (.isCorrectedSearch info)})) - ([service-id query content-filters sort-filter page-url] - (let [service (NewPipe/getService service-id) - url (url-decode page-url) - query-handler (.. service - (getSearchQHFactory) - (fromQuery query (or content-filters '()) (or sort-filter ""))) - info (SearchInfo/getMoreItems service query-handler (Page. url))] - {:items (items/get-items (.getItems info)) - :next-page (j/from-java (.getNextPage info))}))) - -(defn get-kiosk - ([service-id] - (let [service (NewPipe/getService service-id) - extractor (doto (.getDefaultKioskExtractor (.getKioskList service)) - (.fetchPage)) - info (KioskInfo/getInfo extractor)] - {:id (.getId info) - :url (.getUrl info) - :next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getRelatedItems info))})) - ([kiosk-id service-id] - (let [service (NewPipe/getService service-id) - extractor (doto (.getExtractorById (.getKioskList service) kiosk-id nil) - (.fetchPage)) - info (KioskInfo/getInfo extractor)] - {:id (.getId info) - :url (.getUrl info) - :next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getRelatedItems info))})) - ([kiosk-id service-id page-url] - (let [service (NewPipe/getService service-id) - extractor (.getExtractorById (.getKioskList service) kiosk-id nil) - url (url-decode page-url) - kiosk-info (KioskInfo/getInfo extractor) - info (KioskInfo/getMoreItems service (.getUrl kiosk-info) (Page. url))] - {:next-page (j/from-java (.getNextPage info)) - :related-streams (items/get-items (.getItems info))}))) - -(defn get-kiosks - [service-id] - (let [service (NewPipe/getService service-id) - kiosks (.getKioskList service)] - {:default-kiosk (.getDefaultKioskId kiosks) - :available-kiosks (.getAvailableKiosks kiosks)})) - -(defn get-service - [service] - {:id (.getServiceId service) - :info (j/from-java (.getServiceInfo service)) - :base-url (.getBaseUrl service)}) - -(defn get-services - [] - (map get-service (NewPipe/getServices))) diff --git a/src/backend/tau/api/streams.clj b/src/backend/tau/api/streams.clj deleted file mode 100644 index e1bd637..0000000 --- a/src/backend/tau/api/streams.clj +++ /dev/null @@ -1,36 +0,0 @@ -(ns tau.api.streams - (:require - [clojure.java.data :as j] - [ring.util.codec :refer [url-decode]] - [tau.api.items :as items]) - (:import - org.schabi.newpipe.extractor.stream.StreamInfo - org.schabi.newpipe.extractor.NewPipe - org.schabi.newpipe.extractor.localization.DateWrapper - java.time.Instant)) - -(defn get-stream - [url] - (let [info (StreamInfo/getInfo (url-decode url))] - {:name (.getName info) - :url (.getUrl info) - :description (.. info (getDescription) (getContent)) - :upload-date (.getTextualUploadDate info) - :uploader-name (.getUploaderName info) - :uploader-url (.getUploaderUrl info) - :uploader-avatar (.getUploaderAvatarUrl info) - :uploader-verified? (.isUploaderVerified info) - :service-id (.getServiceId info) - :thumbnail-url (.getThumbnailUrl info) - :duration (.getDuration info) - :tags (.getTags info) - :category (.getCategory info) - :view-count (.getViewCount info) - :like-count (when-not (= (.getLikeCount info) -1) (.getLikeCount info)) - :dislike-count (when-not (= (.getDislikeCount info) -1) (.getDislikeCount info)) - :subscriber-count (when-not (= (.getUploaderSubscriberCount info) -1) (.getUploaderSubscriberCount info)) - :audio-streams (j/from-java (.getAudioStreams info)) - :video-streams (j/from-java (.getVideoStreams info)) - :hls-url (.getHlsUrl info) - :dash-mpd-url (.getDashMpdUrl info) - :related-streams (items/get-items (.getRelatedStreams info))})) |