diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-29 01:53:08 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2022-12-29 01:53:08 +0100 |
commit | dfcc61063822dfb0fe699896da312249e93d5439 (patch) | |
tree | c1dc29de45cfe4ae67f104510dc3c4b6d858aa46 /src/backend/tau/api/result.clj | |
parent | 6382ec24c5bbbf93ced1e587103a52b3a63e6045 (diff) |
feat(backend): Remove records and simplify API
Diffstat (limited to 'src/backend/tau/api/result.clj')
-rw-r--r-- | src/backend/tau/api/result.clj | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/backend/tau/api/result.clj b/src/backend/tau/api/result.clj deleted file mode 100644 index 901ea51..0000000 --- a/src/backend/tau/api/result.clj +++ /dev/null @@ -1,59 +0,0 @@ -(ns tau.api.result) - -(defrecord PlaylistResult - [name thumbnail-url url upload-author stream-count]) - -(defrecord ChannelResult - [name description verified? thumbnail-url url - subscriber-count stream-count]) - -(defrecord StreamResult - [name url thumbnail-url upload-author upload-url - upload-avatar upload-date short-description - duration view-count uploaded verified?]) - -(defn get-stream-result - [stream] - (map->StreamResult - {:url (.getUrl stream) - :name (.getName stream) - :thumbnail-url (.getThumbnailUrl stream) - :upload-author (.getUploaderName stream) - :upload-url (.getUploaderUrl stream) - :upload-avatar (.getUploaderAvatarUrl stream) - :upload-date (.getTextualUploadDate stream) - :short-description (.getShortDescription stream) - :duration (.getDuration stream) - :view-count (.getViewCount stream) - :uploaded (if (.getUploadDate stream) - (.. stream (getUploadDate) (offsetDateTime) (toInstant) (toEpochMilli)) - false) - :verified? (.isUploaderVerified stream)})) - -(defn get-channel-result - [channel] - (map->ChannelResult - {:url (.getUrl channel) - :name (.getName channel) - :thumbnail-url (.getThumbnailUrl channel) - :description (.getDescription channel) - :subscriber-count (.getSubscriberCount channel) - :stream-count (.getStreamCount channel) - :verified? (.isVerified channel)})) - -(defn get-playlist-result - [playlist] - (map->PlaylistResult - {:url (.getUrl playlist) - :name (.getName playlist) - :thumbnail-url (.getThumbnailUrl playlist) - :upload-author (.getUploaderName playlist) - :stream-count (.getStreamCount playlist)})) - -(defn get-results - [items] - (map #(case (.name (.getInfoType %)) - "STREAM" (get-stream-result %) - "CHANNEL" (get-channel-result %) - "PLAYLIST" (get-playlist-result %)) - items)) |