Allow listenbrainz to be triggered on every play

This commit is contained in:
Mar0xy 2023-07-31 12:06:31 +02:00
parent ed6f04b6d4
commit 38c1f05c35
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
2 changed files with 11 additions and 4 deletions

View File

@ -81,3 +81,5 @@ export class ListenBrainz {
}
}
}
export { ListenBrainzStore };

View File

@ -6,7 +6,7 @@ import { globalEvents } from "./constants/globalEvents";
import { settings } from "./constants/settings";
import { statuses } from "./constants/statuses";
import { Songwhip } from "./features/songwhip/songwhip";
import { ListenBrainz } from "./features/listenbrainz/listenbrainz";
import { ListenBrainz, ListenBrainzStore } from "./features/listenbrainz/listenbrainz";
import { Options } from "./models/options";
import { downloadFile } from "./scripts/download";
import { addHotkey } from "./scripts/hotkeys";
@ -202,6 +202,11 @@ function playPause() {
}
}
/**
* Clears the old listenbrainz data on launch
*/
ListenBrainzStore.clear();
/**
* Add hotkeys for when tidal is focused
* Reflects the desktop hotkeys found on:
@ -372,6 +377,9 @@ function updateMediaInfo(options: Options, notify: boolean) {
};
player.playbackStatus = options.status == statuses.paused ? "Paused" : "Playing";
}
if (settingsStore.get(settings.ListenBrainz.enabled) && (ListenBrainzStore.get("OldData") as string[][1]) !== options.title) {
ListenBrainz.scrobble(options.title, options.artists, options.status, convertDuration(options.duration));
}
}
}
@ -469,9 +477,6 @@ setInterval(function () {
updateMediaInfo(options, titleOrArtistsChanged);
if (titleOrArtistsChanged) {
updateMediaSession(options);
if (settingsStore.get(settings.ListenBrainz.enabled)) {
ListenBrainz.scrobble(options.title, options.artists, options.status, convertDuration(options.duration));
}
}
});