i hate lastfm

like really really
hate
it
This commit is contained in:
Core 2022-02-17 02:56:41 +00:00
parent cb82ff482d
commit 548688341d
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
3 changed files with 20 additions and 13 deletions

View file

@ -69,9 +69,9 @@ ipcMain.on('nowPlayingItemDidChange', (_event, attributes) => {
CiderPlug.callPlugins('onNowPlayingItemDidChange', attributes);
});
ipcMain.on('lfmItemChange', (_event, attributes) => {
CiderPlug.callPlugins('lfmItemChange', attributes);
});
ipcMain.on('nowPlayingItemDidChangeLastFM', (_event, attributes) => {
CiderPlug.callPlugin('lastfm', 'nowPlayingItemDidChangeLastFM', attributes);
})
app.on('before-quit', () => {
CiderPlug.callPlugins('onBeforeQuit');

View file

@ -265,7 +265,7 @@ export default class LastFMPlugin {
* Runs on song change
* @param attributes Music Attributes
*/
lfmItemChange(attributes: object): void {
nowPlayingItemDidChangeLastFM(attributes: object): void {
if (!this._store.lastfm.filterLoop){
this._lastfm.cachedNowPlayingAttributes = false;
this._lastfm.cachedAttributes = false}

View file

@ -7,9 +7,10 @@ let cache = {playParams: {id: 0}, status: null, remainingTime: 0},
const MusicKitInterop = {
init: function () {
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackStateDidChange, () => {
if (MusicKitInterop.filterTrack(MusicKitInterop.getAttributes(), true, false)) {
global.ipcRenderer.send('playbackStateDidChange', MusicKitInterop.getAttributes())
ipcRenderer.send('wsapi-updatePlaybackState', MusicKitInterop.getAttributes());
const attributes = MusicKitInterop.getAttributes()
if (MusicKitInterop.filterTrack(attributes, true, false)) {
global.ipcRenderer.send('playbackStateDidChange', attributes)
ipcRenderer.send('wsapi-updatePlaybackState', attributes);
// if (typeof _plugins != "undefined") {
// _plugins.execute("OnPlaybackStateChanged", {Attributes: MusicKitInterop.getAttributes()})
// }
@ -23,12 +24,18 @@ const MusicKitInterop = {
/** wsapi */
MusicKit.getInstance().addEventListener(MusicKit.Events.nowPlayingItemDidChange, async () => {
// await MusicKitInterop.modifyNamesOnLocale();
if (MusicKitInterop.filterTrack(MusicKitInterop.getAttributes(), false, true) || !app.cfg.lastfm.filterLoop) {
global.ipcRenderer.send('lfmItemChange', MusicKitInterop.getAttributes());
const attributes = MusicKitInterop.getAttributes()
const trackFilter = MusicKitInterop.filterTrack(attributes, false, true)
if (trackFilter) {
global.ipcRenderer.send('nowPlayingItemDidChange', attributes);
}
global.ipcRenderer.send('nowPlayingItemDidChange', MusicKitInterop.getAttributes());
// LastFM's Custom Call
// await MusicKitInterop.modifyNamesOnLocale();
if (trackFilter || !app.cfg.lastfm.filterLoop) {
global.ipcRenderer.send('nowPlayingItemDidChangeLastFM', attributes);
}
});
MusicKit.getInstance().addEventListener(MusicKit.Events.authorizationStatusDidChange, () => {
@ -69,7 +76,7 @@ const MusicKitInterop = {
const attributes = (nowPlayingItem != null ? nowPlayingItem.attributes : {});
attributes.status = isPlayingExport ?? false;
attributes.name = attributes?.name ?? 'No Title Found';
attributes.name = attributes?.name ?? 'no-title-found';
attributes.artwork = attributes?.artwork ?? {url: ''};
attributes.artwork.url = (attributes?.artwork?.url ?? '').replace(`{f}`, "png");
attributes.playParams = attributes?.playParams ?? {id: 'no-id-found'};
@ -98,7 +105,7 @@ const MusicKitInterop = {
},
filterTrack: function (a, playbackCheck, mediaCheck) {
if (a.title === "No Title Found" || a.playParams.id === "no-id-found") {
if (a.name === 'no-title-found' || a.playParams.id === "no-id-found") {
return;
} else if (mediaCheck && a.playParams.id === cache.playParams.id) {
return;