blob: 901ea5167907436f8a1eb9bf408b33f3edf4d159 (
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
48
49
50
51
52
53
54
55
56
57
58
59
|
(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))
|