radio station compatability

Signed-off-by: Core <core@coredev.uk>
This commit is contained in:
Core 2022-09-14 19:14:22 +01:00
parent bd6552a048
commit 378551bd0c
No known key found for this signature in database
GPG key ID: 2AB8327FBA02D1C0
4 changed files with 6 additions and 10 deletions

View file

@ -241,7 +241,7 @@ export default class DiscordRPC {
} }
// Add the timestamp if its playing and people want them // Add the timestamp if its playing and people want them
if (!this._utils.getStoreValue("connectivity.discord_rpc.hide_timestamp") && attributes.status) { if (!this._utils.getStoreValue("connectivity.discord_rpc.hide_timestamp") && attributes.status && new Date(attributes.endTime).getTime() > 0 && isFinite(attributes.endTime) && isFinite(attributes.startTime)) {
activity.startTimestamp = Date.now() - (attributes?.durationInMillis - attributes?.remainingTime); activity.startTimestamp = Date.now() - (attributes?.durationInMillis - attributes?.remainingTime);
activity.endTimestamp = attributes.endTime; activity.endTimestamp = attributes.endTime;
} }
@ -298,12 +298,6 @@ export default class DiscordRPC {
activity.largeImageKey = "cider"; activity.largeImageKey = "cider";
} }
// Timestamp
if (new Date(attributes.endTime).getTime() < 0) {
delete activity.startTime;
delete activity.endTime;
}
// not sure // not sure
if (!attributes.artistName) { if (!attributes.artistName) {
delete activity.state; delete activity.state;

View file

@ -50,17 +50,17 @@ export default class lastfm {
}); });
this._utils.getIPCMain().on("lastfm:nowPlayingChange", (event: any, attributes: any) => { this._utils.getIPCMain().on("lastfm:nowPlayingChange", (event: any, attributes: any) => {
if (this._utils.getStoreValue("connectivity.lastfm.filter_loop") || this._utils.getStoreValue("general.privateEnabled")) return; if (this._utils.getStoreValue("connectivity.lastfm.filter_loop") || this._utils.getStoreValue("general.privateEnabled") || attributes.type === "radioStation") return;
this.updateNowPlayingTrack(attributes); this.updateNowPlayingTrack(attributes);
}); });
this._utils.getIPCMain().on("lastfm:FilteredNowPlayingItemDidChange", (event: any, attributes: any) => { this._utils.getIPCMain().on("lastfm:FilteredNowPlayingItemDidChange", (event: any, attributes: any) => {
if (this._utils.getStoreValue("general.privateEnabled")) return; if (this._utils.getStoreValue("general.privateEnabled") || attributes.type === "radioStation") return;
this.updateNowPlayingTrack(attributes); this.updateNowPlayingTrack(attributes);
}); });
this._utils.getIPCMain().on("lastfm:scrobbleTrack", (event: any, attributes: any) => { this._utils.getIPCMain().on("lastfm:scrobbleTrack", (event: any, attributes: any) => {
if (this._utils.getStoreValue("general.privateEnabled")) return; if (this._utils.getStoreValue("general.privateEnabled") || attributes.type === "radioStation") return;
this.scrobbleTrack(attributes); this.scrobbleTrack(attributes);
}); });
} }

View file

@ -135,6 +135,7 @@ const MusicKitInterop = {
const attributes = nowPlayingItem != null ? nowPlayingItem.attributes : {}; const attributes = nowPlayingItem != null ? nowPlayingItem.attributes : {};
attributes.songId = attributes.songId ?? attributes.playParams?.catalogId ?? attributes.playParams?.id; attributes.songId = attributes.songId ?? attributes.playParams?.catalogId ?? attributes.playParams?.id;
attributes.type = nowPlayingItem.type ?? "";
attributes.status = isPlayingExport ?? null; attributes.status = isPlayingExport ?? null;
attributes.name = attributes?.name ?? "no-title-found"; attributes.name = attributes?.name ?? "no-title-found";
attributes.artwork = attributes?.artwork ?? { url: "" }; attributes.artwork = attributes?.artwork ?? { url: "" };

View file

@ -1957,6 +1957,7 @@ const app = new Vue({
* @memberOf app * @memberOf app
*/ */
convertTime(seconds, format = "short") { convertTime(seconds, format = "short") {
if (app.mk?.nowPlayingItem?.type === "radioStation") return;
if (isNaN(seconds) || seconds === Infinity) { if (isNaN(seconds) || seconds === Infinity) {
seconds = 0; seconds = 0;
} }