\ No newline at end of file
diff --git a/src/lib/opensubsonic.ts b/src/lib/opensubsonic.ts
index 5d0d421..b2c481a 100644
--- a/src/lib/opensubsonic.ts
+++ b/src/lib/opensubsonic.ts
@@ -6,13 +6,40 @@ export module OpenSubsonic {
export let password = "";
let token = "";
let salt = "";
- export let base = "https://navidrome.neshweb.net";
+ export let base = "https://music.neshweb.net";
const apiVer = "1.16.1"; // Version supported by Navidrome. Variable for easier updating
const clientName = "Lytter";
- export function getApiPath(path: string) {
+ export async function get(path: string, parameters: {parameter: string, value: string}[] = []) {
+ const apiPath = getApiUrl(path, parameters);
+ const res = (await fetch(apiPath));
+ if (res.ok) {
+ switch (res.headers.get("content-type")) {
+ case("application/json"): {
+ return (await res.json())["subsonic-response"];
+ }
+ case("audio/mp4"): {
+ return res;
+ }
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ export function getApiUrl(path: string, parameters: {parameter: string, value: string}[] = []) {
+ let apiPath = generateBasePath(path);
+ parameters.forEach(({parameter, value}) => {
+ apiPath = apiPath + `&${parameter}=${value}`;
+ })
+
+ return apiPath;
+ }
+
+ const generateBasePath = (path: string) => {
if (username === "") {
- let cookie = Cookies.get("subsonicUsername");
+ const cookie = Cookies.get("subsonicUsername");
if (typeof cookie !== "undefined") {
username = cookie;
}
@@ -34,13 +61,13 @@ export module OpenSubsonic {
return `${base}/rest/${path}?u=${username}&s=${salt}&t=${token}&v=${apiVer}&c=${clientName}&f=json`;
}
- function generateToken() {
+ const generateToken = () => {
salt = "staticfornow";
token = Md5.hashStr(password + salt);
}
export function storeCredentials() {
- let options = {
+ const options = {
expires: 7,
path: "/",
sameSite: "strict",
diff --git a/src/lib/time-format.ts b/src/lib/time-format.ts
new file mode 100644
index 0000000..81193e4
--- /dev/null
+++ b/src/lib/time-format.ts
@@ -0,0 +1,7 @@
+export function timeFormat(time: number) {
+ const minutes = (time / 60).toFixed(0).toString();
+ const seconds = time % 60;
+ const secondsString = (seconds < 10) ? '0' + seconds.toString() : seconds.toString()
+
+ return minutes + ":" + secondsString;
+}
\ No newline at end of file
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 351ee4a..487590e 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -2,4 +2,9 @@
import "../app.pcss";
-
\ No newline at end of file
+
+
+
Navbar
+
+
+
\ No newline at end of file
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 5982b0a..993c4b4 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -1,2 +1,159 @@
-