mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 10:23:39 +02:00
Cleanup api interaction; also, not everybody is using my server ;)
This commit is contained in:
parent
73bf88b666
commit
94d6c25d9e
4 changed files with 450 additions and 463 deletions
892
package-lock.json
generated
892
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -14,7 +14,7 @@
|
|||
"create-react-class": "^15.6.3",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2",
|
||||
"shadow-cljs": "^2.3.0"
|
||||
"shadow-cljs": "^2.3.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-flip-move": "^3.0.1",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
(:require [clojure.string :as str]
|
||||
[airsonic-ui.config :as config]))
|
||||
|
||||
(defn ^:private uri-escape [s]
|
||||
(js/encodeURIComponent s))
|
||||
(defn- encode [c]
|
||||
(js/encodeURIComponent c))
|
||||
|
||||
(defn url
|
||||
"Returns an absolute url to an API endpoint"
|
||||
|
|
@ -12,21 +12,20 @@
|
|||
:f "json"
|
||||
:c "airsonic-ui-cljs"
|
||||
:v "1.15.0")
|
||||
(map (fn [[k v]]
|
||||
(str (uri-escape (name k)) "=" (uri-escape v))))
|
||||
(map (fn [[k v]] (str (encode (name k)) "=" (encode v))))
|
||||
(str/join "&"))]
|
||||
(str server (when-not (str/ends-with? server "/") "/") "/rest/" endpoint "?" query)))
|
||||
(str server (when-not (str/ends-with? server "/") "/") "rest/" endpoint "?" query)))
|
||||
|
||||
(defn song-url [server credentials song]
|
||||
(url server "stream" (merge {:id (:id song)} credentials)))
|
||||
|
||||
(defn ^:private api-error?
|
||||
(defn- api-error?
|
||||
"We need to look at the message body because the subsonic api always responds
|
||||
with status 200"
|
||||
[response]
|
||||
(= "failed" (-> response :subsonic-response :status)))
|
||||
|
||||
(defn ^:private error-message
|
||||
(defn- error-message
|
||||
[response]
|
||||
(let [{:keys [code message]} (-> response :subsonic-response :error)]
|
||||
(str "Code " code ": " message)))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
(ns airsonic-ui.config)
|
||||
|
||||
(def server "https://londe.arnes.space")
|
||||
|
||||
(def debug?
|
||||
^boolean goog.DEBUG)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue