mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
move scrobble into subsonic
This commit is contained in:
@@ -522,6 +522,8 @@ export class Subsonic {
|
||||
});
|
||||
|
||||
// todo: make private
|
||||
// todo: should I put a catch in here and force a subsonic fail status?
|
||||
// or there is a catch above, that then throws, perhaps can go in there?
|
||||
getJSON = async <T>(
|
||||
{ username, password }: Credentials,
|
||||
path: string,
|
||||
@@ -739,7 +741,13 @@ export class Subsonic {
|
||||
this.getJSON<SubsonicResponse>(credentials, `/rest/setRating`, {
|
||||
id,
|
||||
rating,
|
||||
}).then(it =>
|
||||
it.status == "ok"
|
||||
);
|
||||
})
|
||||
.then(it => it.status == "ok");
|
||||
|
||||
scrobble = (credentials: Credentials, id: string, submission: boolean) =>
|
||||
this.getJSON<SubsonicResponse>(credentials, `/rest/scrobble`, {
|
||||
id,
|
||||
submission,
|
||||
})
|
||||
.then(it => it.status == "ok")
|
||||
}
|
||||
|
||||
@@ -266,23 +266,12 @@ export class SubsonicMusicLibrary implements MusicLibrary {
|
||||
return undefined;
|
||||
});
|
||||
|
||||
// todo: unit test the difference between scrobble and nowPlaying
|
||||
scrobble = async (id: string) =>
|
||||
this.subsonic
|
||||
.getJSON(this.credentials, `/rest/scrobble`, {
|
||||
id,
|
||||
submission: true,
|
||||
})
|
||||
.then((_) => true)
|
||||
.catch(() => false);
|
||||
this.subsonic.scrobble(this.credentials, id, true);
|
||||
|
||||
nowPlaying = async (id: string) =>
|
||||
this.subsonic
|
||||
.getJSON(this.credentials, `/rest/scrobble`, {
|
||||
id,
|
||||
submission: false,
|
||||
})
|
||||
.then((_) => true)
|
||||
.catch(() => false);
|
||||
this.subsonic.scrobble(this.credentials, id, false);
|
||||
|
||||
searchArtists = async (query: string) =>
|
||||
this.subsonic
|
||||
|
||||
Reference in New Issue
Block a user