aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tau/api/service.clj
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2022-11-21 17:55:28 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2022-12-20 00:54:46 +0100
commit452ccfd567f79126e108f69bb7ebca07b5993bdd (patch)
tree4bc2688977dcd461259683bc89ea7eb94848f627 /src/backend/tau/api/service.clj
feat: Initial commit
Diffstat (limited to 'src/backend/tau/api/service.clj')
-rw-r--r--src/backend/tau/api/service.clj24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/backend/tau/api/service.clj b/src/backend/tau/api/service.clj
new file mode 100644
index 0000000..de2e994
--- /dev/null
+++ b/src/backend/tau/api/service.clj
@@ -0,0 +1,24 @@
+(ns tau.api.service
+ (:require
+ [clojure.java.data :as j]
+ [tau.api.kiosk :as kiosk])
+ (:import
+ org.schabi.newpipe.extractor.NewPipe
+ org.schabi.newpipe.extractor.kiosk.KioskList
+ org.schabi.newpipe.extractor.StreamingService))
+
+(defrecord Service
+ [id info base-url kiosk-list])
+
+(defn get-service-info
+ [service]
+ (map->Service
+ {:id (.getServiceId service)
+ :info (j/from-java (.getServiceInfo service))
+ :base-url (.getBaseUrl service)
+ :kiosk-list (map #(kiosk/get-kiosk-info % (.getServiceId service))
+ (.getAvailableKiosks (.getKioskList service)))}))
+
+(defn get-service-list-info
+ []
+ (map #(get-service-info %) (NewPipe/getServices)))