mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Subsonic scrobble is a GET request...
This commit is contained in:
@@ -244,32 +244,6 @@ export class Navidrome implements MusicService {
|
|||||||
else return response;
|
else return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
post = async (
|
|
||||||
{ username, password }: Credentials,
|
|
||||||
path: string,
|
|
||||||
q: {} = {},
|
|
||||||
config: AxiosRequestConfig | undefined = {}
|
|
||||||
) =>
|
|
||||||
axios
|
|
||||||
.post(`${this.url}${path}`, {
|
|
||||||
params: {
|
|
||||||
...q,
|
|
||||||
u: username,
|
|
||||||
...t_and_s(password),
|
|
||||||
v: "1.16.1",
|
|
||||||
c: "bonob",
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
"User-Agent": "bonob",
|
|
||||||
},
|
|
||||||
...config,
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
if (response.status != 200 && response.status != 206)
|
|
||||||
throw `Navidrome failed with a ${response.status}`;
|
|
||||||
else return response;
|
|
||||||
});
|
|
||||||
|
|
||||||
getJSON = async <T>(
|
getJSON = async <T>(
|
||||||
{ username, password }: Credentials,
|
{ username, password }: Credentials,
|
||||||
path: string,
|
path: string,
|
||||||
@@ -548,7 +522,10 @@ export class Navidrome implements MusicService {
|
|||||||
},
|
},
|
||||||
scrobble: async (id: string) =>
|
scrobble: async (id: string) =>
|
||||||
navidrome
|
navidrome
|
||||||
.post(credentials, `/rest/scrobble`, { id, submission: true })
|
.get(credentials, `/rest/scrobble`, {
|
||||||
|
id,
|
||||||
|
submission: true,
|
||||||
|
})
|
||||||
.then((_) => true)
|
.then((_) => true)
|
||||||
.catch(() => false),
|
.catch(() => false),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2170,9 +2170,9 @@ describe("Navidrome", () => {
|
|||||||
it("should return true", async () => {
|
it("should return true", async () => {
|
||||||
const id = uuid();
|
const id = uuid();
|
||||||
|
|
||||||
mockGET.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)));
|
mockGET
|
||||||
|
.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)))
|
||||||
mockPOST.mockImplementationOnce(() => Promise.resolve(ok(EMPTY)));
|
.mockImplementationOnce(() => Promise.resolve(ok(EMPTY)));
|
||||||
|
|
||||||
const result = await navidrome
|
const result = await navidrome
|
||||||
.generateToken({ username, password })
|
.generateToken({ username, password })
|
||||||
@@ -2182,7 +2182,7 @@ describe("Navidrome", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(true);
|
expect(result).toEqual(true);
|
||||||
|
|
||||||
expect(mockPOST).toHaveBeenCalledWith(`${url}/rest/scrobble`, {
|
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, {
|
||||||
params: {
|
params: {
|
||||||
id,
|
id,
|
||||||
submission: true,
|
submission: true,
|
||||||
@@ -2197,14 +2197,14 @@ describe("Navidrome", () => {
|
|||||||
it("should return false", async () => {
|
it("should return false", async () => {
|
||||||
const id = uuid();
|
const id = uuid();
|
||||||
|
|
||||||
mockGET.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)));
|
mockGET
|
||||||
|
.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)))
|
||||||
mockPOST.mockImplementationOnce(() =>
|
.mockImplementationOnce(() =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
status: 500,
|
status: 500,
|
||||||
data: {},
|
data: {},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await navidrome
|
const result = await navidrome
|
||||||
.generateToken({ username, password })
|
.generateToken({ username, password })
|
||||||
@@ -2214,7 +2214,7 @@ describe("Navidrome", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(false);
|
expect(result).toEqual(false);
|
||||||
|
|
||||||
expect(mockPOST).toHaveBeenCalledWith(`${url}/rest/scrobble`, {
|
expect(mockGET).toHaveBeenCalledWith(`${url}/rest/scrobble`, {
|
||||||
params: {
|
params: {
|
||||||
id,
|
id,
|
||||||
submission: true,
|
submission: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user