blob: 676af3e3dc3e4c818583bbc6d86fbd442e551e5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
(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))
|