Backend implementation of filter media type

This commit is contained in:
Core 2022-06-23 03:42:51 +01:00
parent 7e6f3bd17e
commit 873c626096
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
2 changed files with 6 additions and 5 deletions

View file

@ -131,6 +131,7 @@ export class Store {
"enabled": false,
"scrobble_after": 50,
"filter_loop": false,
"filter_types": [],
"secrets": {
"username": "",
"key": ""

View file

@ -34,10 +34,10 @@ export default class lastfm {
this.initializeLastFM("", this._apiCredentials)
}
onReady(win: Electron.BrowserWindow): void {
onReady(_win: Electron.BrowserWindow): void {
// Register the ipcMain handlers
this._utils.getIPCMain().handle('lastfm:url', (event: any) => {
this._utils.getIPCMain().handle('lastfm:url', (_event: any) => {
// console.debug('lastfm:url', event)
return this._lfm.getAuthenticationUrl({"cb": "cider://auth/lastfm"})
})
@ -47,7 +47,7 @@ export default class lastfm {
this.authenticateLastFM(token)
})
this._utils.getIPCMain().on('lastfm:disconnect', (event: any) => {
this._utils.getIPCMain().on('lastfm:disconnect', (_event: any) => {
this._lfm.setSessionCredentials(null, null);
this._authenticated = false;
console.debug('[lastfm] [disconnect] Disconnected')
@ -170,7 +170,7 @@ export default class lastfm {
* @private
*/
private scrobbleTrack(attributes: any): void {
if (!this._authenticated || !attributes || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._scrobbleCache.track === attributes.lfmTrack.name)) return;
if (!this._authenticated || !attributes || this._utils.getStoreValue("connectivity.lastfm.filter_types")[attributes.playParams.kind] || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._scrobbleCache.track === attributes.lfmTrack.name)) return;
if (this._scrobbleDelay) {
clearTimeout(this._scrobbleDelay);
@ -208,7 +208,7 @@ export default class lastfm {
}
private updateNowPlayingTrack(attributes: any): void {
if (!this._authenticated || !attributes || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._nowPlayingCache.track === attributes.lfmTrack.name)) return;
if (!this._authenticated || !attributes || this._utils.getStoreValue("connectivity.lastfm.filter_types")[attributes.playParams.kind] || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._nowPlayingCache.track === attributes.lfmTrack.name)) return;
const nowPlaying = {
'artist': attributes.lfmTrack.artist.name,