diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-20 00:35:56 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-20 00:54:58 +0100 |
commit | e71fdc8dbac5c77d6c2fd252f31fc12cd6375e30 (patch) | |
tree | 890953876b06a647e6790715f2580aa94aebe4a7 /src/backend/tau/api/stream.clj | |
parent | e4714f94ff6d01847fa61c33c678b6d856c3b30a (diff) |
fix: Fix related streams on API endpoints
Diffstat (limited to 'src/backend/tau/api/stream.clj')
-rw-r--r-- | src/backend/tau/api/stream.clj | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/tau/api/stream.clj b/src/backend/tau/api/stream.clj index d0a7c81..63ab183 100644 --- a/src/backend/tau/api/stream.clj +++ b/src/backend/tau/api/stream.clj @@ -1,5 +1,7 @@ (ns tau.api.stream (:require + [tau.api.playlist :as playlist] + [tau.api.channel :as channel] [clojure.java.data :as j] [ring.util.codec :refer [url-decode]]) (:import @@ -21,7 +23,7 @@ upload-avatar upload-date short-description duration view-count uploaded verified?]) -(defn get-stream-result +(defn get-result [stream] (map->StreamResult {:url (.getUrl stream) @@ -36,14 +38,23 @@ :view-count (.getViewCount stream) :uploaded (if (.getUploadDate stream) (.. stream (getUploadDate) (offsetDateTime) (toInstant) (toEpochMilli)) - -1) + false) :verified? (.isUploaderVerified stream)})) -(defn get-stream-info +(defn get-results + [items] + (map #(case (.name (.getInfoType %)) + "STREAM" (get-result %) + "CHANNEL" (channel/get-result %) + "PLAYLIST" (playlist/get-result %)) + items)) + +(defn get-info [url] (let [info (StreamInfo/getInfo (url-decode url))] (map->Stream {:name (.getName info) + :url (.getUrl info) :description (.. info (getDescription) (getContent)) :upload-date (.getTextualUploadDate info) :upload-author (.getUploaderName info) @@ -63,4 +74,4 @@ :video-streams (j/from-java (.getVideoStreams info)) :hls-url (.getHlsUrl info) :dash-mpd-url (.getDashMpdUrl info) - :related-streams (map #(get-stream-result %) (.getRelatedStreams info))}))) + :related-streams (get-results (.getRelatedStreams info))}))) |