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/kiosk.clj | |
parent | 6382ec24c5bbbf93ced1e587103a52b3a63e6045 (diff) |
feat(backend): Remove records and simplify API
Diffstat (limited to 'src/backend/tau/api/kiosk.clj')
-rw-r--r-- | src/backend/tau/api/kiosk.clj | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/backend/tau/api/kiosk.clj b/src/backend/tau/api/kiosk.clj deleted file mode 100644 index 4243a32..0000000 --- a/src/backend/tau/api/kiosk.clj +++ /dev/null @@ -1,47 +0,0 @@ -(ns tau.api.kiosk - (:require - [clojure.java.data :as j] - [ring.util.codec :refer [url-decode]] - [tau.api.result :as result]) - (:import - org.schabi.newpipe.extractor.StreamingService - org.schabi.newpipe.extractor.Page - org.schabi.newpipe.extractor.kiosk.KioskInfo - org.schabi.newpipe.extractor.NewPipe)) - -(defrecord KioskList - [default-kiosk available-kiosks]) - -(defrecord Kiosk - [id url next-page related-streams]) - -(defrecord KioskPage - [next-page related-streams]) - -(defn get-info - ([kiosk-id service-id] - (let [service (NewPipe/getService service-id) - extractor (.getExtractorById (.getKioskList service) kiosk-id nil) - info (KioskInfo/getInfo extractor)] - (map->Kiosk - {:id (.getId info) - :url (.getUrl info) - :next-page (j/from-java (.getNextPage info)) - :related-streams (result/get-results (.getRelatedItems info))}))) - ([kiosk-id service-id page-url] - (let [service (NewPipe/getService service-id) - extractor (.getExtractorById (.getKioskList service) kiosk-id nil) - url (url-decode page-url) - kiosk-info (KioskInfo/getInfo extractor) - info (KioskInfo/getMoreItems service (.getUrl kiosk-info) (Page. url))] - (map->KioskPage - {:next-page (j/from-java (.getNextPage info)) - :related-streams (result/get-results (.getItems info))})))) - -(defn get-kiosks - [service-id] - (let [service (NewPipe/getService service-id) - kiosks (.getKioskList service)] - (map->KioskList - {:default-kiosk (.getDefaultKioskId kiosks) - :available-kiosks (.getAvailableKiosks kiosks)}))) |