Add unique session identifier to OpenSubsonic for improved behaviour with getNowPlaying
This commit is contained in:
parent
ff396e8ca2
commit
65f0e6776e
1 changed files with 19 additions and 5 deletions
|
@ -1,14 +1,28 @@
|
|||
import {Md5} from "ts-md5";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function getIdent(): string {
|
||||
let cookie = Cookies.get("subsonicPlayerIdent");
|
||||
if (typeof cookie === "undefined") {
|
||||
cookie = Math.random().toString(36).slice(2);
|
||||
}
|
||||
const options = {
|
||||
expires: 7,
|
||||
path: "/",
|
||||
sameSite: "strict",
|
||||
};
|
||||
Cookies.set("subsonicPlayerIdent", cookie, options);
|
||||
return cookie;
|
||||
}
|
||||
|
||||
export module OpenSubsonic {
|
||||
export let username = "";
|
||||
export let password = "";
|
||||
let token = "";
|
||||
let salt = "";
|
||||
export let username: string = "";
|
||||
export let password: string = "";
|
||||
let token: string = "";
|
||||
let salt: string = "";
|
||||
export let base = "https://music.neshweb.net";
|
||||
const apiVer = "1.16.1"; // Version supported by Navidrome. Variable for easier updating
|
||||
const clientName = "Lydstyrke";
|
||||
export const clientName = "Lydstyrke-" + getIdent();
|
||||
|
||||
export async function get(path: string, parameters: Array<Parameter> = []) {
|
||||
const apiPath = getApiUrl(path, parameters);
|
||||
|
|
Loading…
Reference in a new issue