From 742e606c09a876b0b3eeddc53be2447b5d2a09ff Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Thu, 16 Jun 2022 16:14:53 +0100 Subject: [PATCH] filter loop fixes --- src/main/plugins/lastfm.ts | 14 +++++++++++--- src/preload/cider-preload.js | 2 ++ src/renderer/views/pages/settings.ejs | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/plugins/lastfm.ts b/src/main/plugins/lastfm.ts index af63f4a1..bf0b88e5 100644 --- a/src/main/plugins/lastfm.ts +++ b/src/main/plugins/lastfm.ts @@ -52,6 +52,11 @@ export default class lastfm { this._authenticated = false; console.debug('[lastfm] [disconnect] Disconnected') }) + + this._utils.getIPCMain().on('lastfm:nowPlayingChange', (event: any, attributes: any) => { + if (this._utils.getStoreValue("lastfm.filter_loop")) return; + this.onNowPlayingItemDidChange(attributes) + }) } /** @@ -123,15 +128,18 @@ export default class lastfm { * @private */ private verifyTrack(attributes: any): object { - if (!attributes) return {}; + if (!attributes) return attributes; if (!attributes.lfmAlbum) { + console.log(attributes.artistName) + console.log(attributes.albumName) return this._lfm.album.getInfo({ "artist": attributes.artistName, "album": attributes.albumName }, (err: any, data: any) => { if (err) { - console.error(`[${lastfm.name}] [album.getInfo] Error: ${err}`) + console.error(`[${lastfm.name}] [album.getInfo] Error: ${typeof err === "string" ? err : err.message}`) + console.error(err) return {}; } if (data) { @@ -142,7 +150,7 @@ export default class lastfm { } else { return this._lfm.track.getCorrection(attributes.artistName, attributes.name, (err: any, data: any) => { if (err) { - console.error(`[${lastfm.name}] [track.getCorrection] Error: ${err}`) + console.error(`[${lastfm.name}] [track.getCorrection] Error: ${typeof err === "string" ? err : err.message}`) console.error(err) return {}; } diff --git a/src/preload/cider-preload.js b/src/preload/cider-preload.js index 3923fbd3..57ae5df3 100644 --- a/src/preload/cider-preload.js +++ b/src/preload/cider-preload.js @@ -29,6 +29,8 @@ const MusicKitInterop = { global.ipcRenderer.send('nowPlayingItemDidChange', attributes); } + global.ipcRenderer.send('lastfm:nowPlayingChange', attributes); + if (MusicKit.getInstance().nowPlayingItem) { await this.sleep(750); MusicKit.getInstance().playbackRate = app.cfg.audio.playbackRate; diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index c64432f1..170dcfd8 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -1081,7 +1081,7 @@